简体   繁体   中英

New open xml word doc hyperlinks look like normal text

I'm generating a MS Word document using the OpenXML SDK. I can successfully create a new document and insert hyperlinks. The problem is when opened in MS Word 2010, the link looks like normal text. After examining the file /word/styles.xml I've found it doesn't contain the "Hyperlink" style. How can I programmatically access or create this classic style?

Paragraph res = new Paragraph(
new Hyperlink(new ProofError() { Type = ProofingErrorValues.GrammarStart },
                             new Run(
                                 new RunProperties(
                                 new RunStyle() { Val = "Hyperlink" }
                                 ),
                                 new Text("Text")
                             )
                             { RsidRunProperties = uniqueId},
                             new ProofError() { Type = ProofingErrorValues.GrammarEnd }
                             )
                         {
                             Id = relationid,
                             History = new DocumentFormat.OpenXml.OnOffValue(true)
                         }
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM