我想你的例子,實際上它只是做了大膽的我,而不是強調。我的工作有點,並結束了與此:
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