0

I have been researching for the best thirdparty dll to generate word document. Finally I found NPOI is very good to write word document.

But I am unable to add the hyperlink to document.

san thu
  • 1
  • 1
  • You will have very less documentation availability for NPOI. Whay can't use the Open XML - https://msdn.microsoft.com/library/office/documentformat.openxml.packaging.wordprocessingdocument.aspx – MBB Sep 28 '18 at 09:55
  • Thank you @MaheshB, first I had decided to use Open XML because it is one of the Microsoft product. But after compare it against NPOI I feel NPOI has been updating its dll and fixing their bugs with the updated features. Please check this out and help me understand: https://dotnet.libhunt.com/compare-npoi-vs-open-xml-sdk – san thu Sep 28 '18 at 13:41

1 Answers1

0

The new NPOI examples is added at https://github.com/nissl-lab/npoi-examples/tree/main/xwpf/CreateHyperlink

        XWPFParagraph paragraph = doc.CreateParagraph();
        XWPFRun run = paragraph.CreateRun();
        run.SetText("This is a text paragraph having ");

        XWPFHyperlinkRun hyperlinkrun = CreateHyperlinkRun(paragraph, "https://www.google.com");
        hyperlinkrun.SetText("a link to Google");
        hyperlinkrun.SetColor("0000FF");
        hyperlinkrun.SetUnderline(UnderlinePatterns.Single);
Tony Qu
  • 676
  • 8
  • 14