使用docx.dll创建超链接?

时间:2016-03-08 20:34:13

标签: c# ms-word openxml docx

如何动态创建带有docx.dll的超链接,目前在下面尝试过但不能正常工作

using (DocX document = DocX.Create(@"Test.docx"))
{
    // Add a hyperlink to this document.
    Hyperlink h = document.AddHyperlink
    ("Google", new Uri("http://www.google.com"));

    // Add a new Paragraph to this document.
    Paragraph p = document.InsertParagraph();
    p.Append("My favourite search engine is ");
    p.AppendHyperlink(h);
    p.Append(", I think it's great.");

    // Save all changes made to this document.
    document.Save();
}

1 个答案:

答案 0 :(得分:0)

如何使用p.AppendHyperlink("www.google.com", "Google", HyperlinkType.WebLink);
此外,您可以从Insert Hyperlink to Word in C#获取参考。