tags:

views:

905

answers:

2

I am trying to insert new lines into an Excel XML document. The entity that I need to insert is 
 but whenever I insert that into PHP DOM, it just converts it to a normal line break.

This is what I am getting:

<Cell><Data>text
text2
</Data></Cell>

This is what I want:

<Cell><Data>text&#10;text2&#10;</Data></Cell>

I cannot figure out how to insert a new line and get it to encode that way, or add that character without it either double encoding it, or converting it to a new line.

Thanks for the help!

A: 

Use a CDATA section...

ozczecho
A: 

When using CDATA and placing &#10; within the CDATA, Excel sees it as the actual text, not the character. What I had to do is place the literal line break into the CDATA section and set the cell style to wrap. I added this to the default XML Style:

<Alignment ss:Vertical="Bottom" ss:WrapText="1"/>

That should do it for anyone looking to do this with PHP DOM, or any other XML creator.

Daniel