How to edit word documents with php?

大憨熊 提交于 2019-12-09 18:49:19

问题


I have an existing word document in my computer and like to edit this file from my website (using PHP). I was able to find PHPWORD but this deals with new documents only. I don't want to code PHP for the whole document, instead wish to use it for the stuff that varies.

Does anybody know any way out?


回答1:


https://github.com/PHPOffice/PHPWord

PHPWord also features a Reader which can be used to edit existing documents.




回答2:


@nssmart,

Yes,mark a section on your word document with a variable such as {value1} and then, if you have PHPWORD downloaded, you can replace that section using code

$PHPWord = new PHPWord();

$document = $PHPWord->loadTemplate(Doc location);

$document->setValue('value1', 'Description');

This can be used to fill data in tables also.



来源:https://stackoverflow.com/questions/34975256/how-to-edit-word-documents-with-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!