【发布时间】:2016-10-25 17:56:19
【问题描述】:
我正在按照这个结构将字符串中的文本添加到 OpenXML 运行中,它是 Word 文档的一部分。
字符串有新的行格式,甚至段落缩进,但是当文本插入运行时,这些都会被删除。如何保存?
Body body = wordprocessingDocument.MainDocumentPart.Document.Body;
String txt = "Some formatted string! \r\nLook there should be a new line here!\r\n\r\nAndthere should be 2 new lines here!"
// Add new text.
Paragraph para = body.AppendChild(new Paragraph());
Run run = para.AppendChild(new Run());
run.AppendChild(new Text(txt));
【问题讨论】:
-
旁注:里面有新行的段落对我来说听起来很奇怪。你确定这是你最终需要达到的目标吗?
标签: c# parsing ms-word openxml office-interop