我遵循这个结构来将字符串中的文本添加到OpenXML运行中,它们是Word文档的一部分。如何在OpenXML中使用格式保留字符串段落,运行,文本?
该字符串具有新的行格式,甚至段落缩进,但是当文本插入到运行中时,这些全部都会被剥离。我该如何保存它?
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));
备注:带有新线条的段落听起来很奇怪。你确定这是你最终需要实现的吗? –