docx - Why Office OpenXML splits text between tags and how to prevent it? -


i'm trying work docx files using phpword library , templating system. have found , updated someones (cant remember name, not important) path library can work tables (replicate rows , use standard setvalue() phpword on each of row).

if create own document, data in xml in normal structure, variable replaced ${variable} in own tag this:

<w:tbl>     <w:tr>         ...          ${variable}     </w:tr> </w:tbl> 

i simplified code, in actual code there number of other tags descibing sizes, styles, etc.

my problem have proccess documents other people prohibited make big changes, document @ point table 1 blank row. add ${variable} variables , run through phpword. problem is, fails. after doing research , found out source xml looks this:

    ....         ...          ${va          ...          riab          ...          le}     .... 

(again heavily simplified, picture)

this structure problem me, because function clone rows uses strpos(), substr() , regular expressions work , not work structure (and cant imagine elegant way so).

so question - know why docx , how prevent him? looking solution via word, not php (i need current functions work without editing)

i have worked problem lot:

in word, document can saved this

  <w:t>{</w:t>...   <w:t>variable</w:t>   <w:t>}</w:t> 

i have therefore create js library works if variable names splitted: docxgenjs (works server side too) . have found out during development variables names aren't splitted if:

  • the text find composed of a-za-z characters (no {, $ or })
  • the text might splitted if text wasn't written in 1 stroke: example, if make spelling mistake, , write ${varuable} , make edit -> ${variable}, text inside xml highly going splitted. have write variable names in 1 stroke, , if wish edit one, rewrite variable name completely.

i don't think there's way fix docx document 1 command in word, , rewriting variables write them in 1 stroke should work.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -