Insert data to .docx and .odt in PHP
We insert data from a database into a word-document (Word 2007). There are tables in it, a开发者_运维百科nd every set of data should be on a seperate page.
Right now PHPWord covers our needs pretty good. But some of our customers use OpenOffice.org, and PHPWord doesnt seem to create a 100% correct Word-Document. Word can handle that errors, but OpenOffice cant. So, my question is: Is there any other good PHP-library that creates documents both Editors can read, or is it better use a library for Word and another one for OpenOffice.org? (For OpenOffice.org I would use http://www.odtphp.com/). I would prefer to use a single library which creates a Word document.Okay, we found the solution. I'll write it in here just in case somebody has the same problem. The files were missformated in OpenOffice.org because PhpWord formats the xml with spaces and newlines. Word removes this lines and shows the document how its supposed to be, but OOo inserts a newline for every newline in the xml-doc in the document is shows. Changing the lines 79 and 84 inside Shared/XMLWriter.php did the trick.
// Set default values
// proposed to be false in production version
$this->_xmlWriter->setIndent(true);
//$this->_xmlWriter->setIndent(false);
// Set indent
// proposed to be '' in production version
$this->_xmlWriter->setIndentString(' ');
//$this->_xmlWriter->setIndentString('');
精彩评论