【发布时间】:2015-10-23 02:59:18
【问题描述】:
我编写了一个程序,它可以从 SQL Server 表中提取信息并将信息放入 MS WORD 中。
foreach (String note in doc_object.alJobNotes)
{
String formattednote = "";
newTextElement = xdoc.CreateElement("w:t", wordmlNamespace);
formattednote = note.Replace(Environment.NewLine, " ");
XmlText newText = xdoc.CreateTextNode(formattednote);
newTextElement.AppendChild(newText);
XmlAttribute xmlSpace = xdoc.CreateAttribute(
"xml", "space",
"http://www.w3.org/XML/1998/namespace");
xmlSpace.Value = "preserve";
newTextElement.Attributes.Append(xmlSpace);
ChildNode.ParentNode.InsertAfter(newTextElement, ChildNode);
EmptyElement = xdoc.CreateElement("w:br", wordmlNamespace);
EmptyElement.Attributes.Append(xmlSpace);
ChildNode.ParentNode.InsertAfter(EmptyElement, ChildNode);
ChildNode.ParentNode.InsertAfter(EmptyElement, ChildNode);
ChildNode.ParentNode.InsertAfter(EmptyElement, ChildNode);
ChildNode.ParentNode.InsertAfter(EmptyElement, ChildNode);
}
但是,当我打开 Ms Word 时,回车的地方只显示
我尝试将其替换为&#10;、(char)13、(char)10、<br/>、<w:cr>,但我找不到如何操作。
有什么建议吗?
【问题讨论】:
标签: c# sql-server xml