私はあなたの例を試しましたが、実際には太字で下線を引いていませんでした。私はそれを少し処理し、これで終了しました:
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 }
Underline クラスのコンストラクターに任せるのではなく、必要な下線の種類を指定する必要があります。指定Single
しただけでうまくいきました。