phpWord generated documents behave different in MSWord and OpenOffice? bug? -
we using phpword generate word documents. have @ moment following: if use addtext() newlines, tabs, etc. works in open office (same in source xml file) don't work in ms word. (there few question in so, went textrun ...) if use addtextrun() , addtextbreak(), linebreaks, tabs, etc. shown in ms word ... not in openoffice ... generating document word2007
it's disappointing.... did lot of test, same result.
is known issue? have solution have "same/similar" display when opening document in msword or open office?
here more info regarding issue: generate file, , open on ms word , open office
here see in openoffice or libreoffice
as may see, behavior of text , text-run linebreaks opposite depending suite use open document.
what want accomplish create reports based on content retrieved data base. content may may have line breaks, tabs, etc.
as per requested, here of our code. make wrapper handle phpword objects, here relevant parts of our code;
$this->phpword = new phpword(); function setsectionfromxmlnode($sectionnode, $format = null) { $section = $this->phpword->addsection($format); foreach ($sectionnode->text $textnode) { $format = $this->gettextformatfromxmlnode($textnode); $section->addtext($textnode, $format); } foreach ($sectionnode->{'text-run'} $textrunnode) { $format = $this->gettextformatfromxmlnode($textrunnode); $textchunk = $textrunnode->__tostring(); $textlines = preg_split("/\\r\\n|\\r|\\n/", $textchunk); $textrun = $section->addtextrun(); $textrun->addtext(array_shift($textlines),$format); foreach($textlines $line) { $textrun->addtextbreak(); $textrun->addtext($line,$format); } } } this xml
<document> <section> <text>this new section. spaces, tabs, , linebreaks should preserved</text> <text> 1 2 3 lines </text> <text-run> 1 2 3 lines </text-run> </section> </document>
Comments
Post a Comment