我在向我的 word 文档添加超链接时遇到问题。我不知道该怎么做。我想使用打开的 xml 从我的 C# 代码在 word 文档中建立链接。是否有其他解决方案仅使用 href 或类似的东西?网上有一个来自 Open XML 的 HyperLink 类,但是如何使用它呢?
最佳答案
试试这个
using (WordprocessingDocument doc = WordprocessingDocument.Open("", true))
{
doc.MainDocumentPart.Document.Body.AppendChild(
new Paragraph(
new Hyperlink(new Run(new Text("Click here")))
{
Anchor = "Description",
DocLocation = "location",
}
)
);
doc.MainDocumentPart.Document.Save();
}
关于c# - 如何使用 Open XML 将超链接添加到 Word docx 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16085754/