Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit word documents with php?

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?

like image 454
Adarsh Avatar asked Jan 24 '16 11:01

Adarsh


People also ask

How can I edit a DOCX file in PHP?

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".

How do I write to a word document in PHP?

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.

Is PHP coding available in MS Word?

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.

How read data from docx file in PHP?

You can use PHPOffice to read docx content in PHP. and then print_r the $content to see the content as string.


1 Answers

https://github.com/PHPOffice/PHPWord

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

like image 111
mazedlx Avatar answered Oct 05 '22 19:10

mazedlx