The sample demonstrates how to insert hyperlinks into a Word document.
private void button1_Click(object sender, EventArgs e) { //Create word document Document document = new Document(); InsertHyberlink(document.AddSection()); //Save doc file. document.SaveToFile("Sample.doc",FileFormat.Doc); //Launching the MS Word file. WordDocViewer("Sample.doc"); } private void InsertHyberlink(Section section) { Paragraph paragraph = section.AddParagraph(); paragraph.AppendText("Spire.XLS for .NET \r\n e-iceblue company Ltd. 2002-2010 All rights reserverd"); paragraph.ApplyStyle(BuiltinStyle.Heading2); paragraph = section.AddParagraph(); paragraph.AppendText("Home page"); paragraph.ApplyStyle(BuiltinStyle.Heading2); paragraph = section.AddParagraph(); paragraph.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com", HyperlinkType.WebLink); paragraph = section.AddParagraph(); paragraph.AppendText("Contact US"); paragraph.ApplyStyle(BuiltinStyle.Heading2); paragraph = section.AddParagraph(); paragraph.AppendHyperlink("mailto:support@e-iceblue.com", "support@e-iceblue.com", HyperlinkType.EMailLink); } private void WordDocViewer(string fileName) { try { System.Diagnostics.Process.Start(fileName); } catch { } }
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click 'Create word document Dim document_Renamed As New Document() InsertHyberlink(document_Renamed.AddSection()) 'Save doc file. document_Renamed.SaveToFile("Sample.doc",FileFormat.Doc) 'Launching the MS Word file. WordDocViewer("Sample.doc") End Sub Private Sub InsertHyberlink(ByVal section_Renamed As Section) Dim paragraph_Renamed As Paragraph = section_Renamed.AddParagraph() paragraph_Renamed.AppendText("Spire.XLS for .NET " & vbCrLf & " e-iceblue company Ltd. 2002-2010 All rights reserverd") paragraph_Renamed.ApplyStyle(BuiltinStyle.Heading2) paragraph_Renamed = section_Renamed.AddParagraph() paragraph_Renamed.AppendText("Home page") paragraph_Renamed.ApplyStyle(BuiltinStyle.Heading2) paragraph_Renamed = section_Renamed.AddParagraph() paragraph_Renamed.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com", HyperlinkType.WebLink) paragraph_Renamed = section_Renamed.AddParagraph() paragraph_Renamed.AppendText("Contact US") paragraph_Renamed.ApplyStyle(BuiltinStyle.Heading2) paragraph_Renamed = section_Renamed.AddParagraph() paragraph_Renamed.AppendHyperlink("mailto:support@e-iceblue.com", "support@e-iceblue.com", HyperlinkType.EMailLink) End Sub Private Sub WordDocViewer(ByVal fileName As String) Try Process.Start(fileName) Catch End Try End Sub