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?
docx_editor.php * you can add, modify, or remove content or structure of the document. // Create the Object. $zip = new ZipArchive(); // Use same filename for "save" and different filename for "save as".
To generate a Word document you need to create a PhpWord object which you then fill with the contents: $phpWord = new PhpWord(); To create your Word file from this object you need to save it using the Word2007 Writer: $objWriter = IOFactory::createWriter($phpWord, 'Word2007'); $objWriter->save('MyDocument.
It should be noted that PHP is a server encrypting language which is used to make dynamic and interactive web pages. Special tools and editors are used to writing PHP code and MS Word is not among them. Hence, we conclude that the PHP Coding feature is not available in MS Word.
You can use PHPOffice to read docx content in PHP. and then print_r the $content to see the content as string.
https://github.com/PHPOffice/PHPWord
PHPWord also features a Reader which can be used to edit existing documents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With