DotNet版 - Office 2007 Office Open XML Format New Line |
|
|
|
|
|
z***a 发帖数: 138 | 1 Hi,
I am fixing a bug in an app that builds a Word 2007 document using
Office Open XML format. There is already a .zip package for the
document. The App will build an XML formatted data which then is
imported by the document.
In the document there is one field for a street address and there is a
corresponding XML node with address data containing street address line
1 and 2. (City, State, zip is in another field so they do not matter).
I need to split the address into two lines if second line address
exists. Such as:
123 Main St.
Apt. A
The app is written using C#. I inserted \r and \n between two address
lines when the XML is built. XML looks fine but when the word document
is built and opened, the address is still in one line. Why \r \n are not
working? How to fix that?
Also, I tried \t and \t is preserved in word document.
And I tried XML special characters
and
but they don't work.
Thanks for your help. | s***o 发帖数: 2191 | 2 Can you just "Split" the string with "\n" or whatever delimiter you specify,
then process the resulting strings as separate lines?
There is also a CarriageReturn class that may be useful:
http://msdn.microsoft.com/en-us/library/documentformat.openxml. | s**m 发帖数: 1564 | 3 the word document is made already. there is one field for street address
line 1 & 2 in the word form document. So the string is concatenated from two
database field values. I suggested to have two fields for line 1 and 2. but
my suggestion was turned down.
I am new to Office Open XML so I don't know why \r and \n format get lost
when word document imports the stream, but \t is preserved.
specify,
【在 s***o 的大作中提到】 : Can you just "Split" the string with "\n" or whatever delimiter you specify, : then process the resulting strings as separate lines? : There is also a CarriageReturn class that may be useful: : http://msdn.microsoft.com/en-us/library/documentformat.openxml.
| s***o 发帖数: 2191 | 4 Is it based on the VS Office template, or is it created with OpenXml
APIs from scratch? In either way, if you have control to the generated
xml, then you can always parse the string and express it "correctly".
I don't know much about OpenXML either plus it's all about Excel. You
can post your question on the openxml forum:
http://openxmldeveloper.org/forums/default.aspx
address
from two
2. but
lost
【在 s**m 的大作中提到】 : the word document is made already. there is one field for street address : line 1 & 2 in the word form document. So the string is concatenated from two : database field values. I suggested to have two fields for line 1 and 2. but : my suggestion was turned down. : I am new to Office Open XML so I don't know why \r and \n format get lost : when word document imports the stream, but \t is preserved. : : specify,
| c**t 发帖数: 2744 | 5 Rename your .docx file to .zip, use 7zip to open the archive, find xml spot
which has correct line-break, see what's there. You can then change your
code.
【在 z***a 的大作中提到】 : Hi, : I am fixing a bug in an app that builds a Word 2007 document using : Office Open XML format. There is already a .zip package for the : document. The App will build an XML formatted data which then is : imported by the document. : In the document there is one field for a street address and there is a : corresponding XML node with address data containing street address line : 1 and 2. (City, State, zip is in another field so they do not matter). : I need to split the address into two lines if second line address : exists. Such as:
|
|
|
|
|
|
|