我想你的例子,实际上它只是做了大胆的我,而不是强调。我的工作有点,并结束了与此:
using (WordprocessingDocument doc = WordprocessingDocument.Open(destFileName, true))
{
Run run = new Run();
RunProperties runProperties = new RunProperties();
runProperties.AppendChild<Underline>(new Underline() { Val = DocumentFormat.OpenXml.Wordprocessing.UnderlineValues.Single });
runProperties.AppendChild<Bold>(new Bold());
run.AppendChild<RunProperties>(runProperties);
run.AppendChild(new Text("test"));
//Note: I had to create a paragraph element to place the run into.
Paragraph p = new Paragraph();
p.AppendChild(run);
doc.MainDocumentPart.Document.Body.AppendChild(p);
}
基本上,这个改变:new Underline() { Val = DocumentFormat.OpenXml.Wordprocessing.UnderlineValues.Single }
你必须指定要下划线的类型,而不是仅仅把它留给下划线类的构造函数。我只是指定“单一”,它为我工作。
享受,
感谢您的帮助! – Aelios 2012-08-27 07:14:20