|
WordDocument document = new WordDocument(); document.EnsureMinimal(); IWTable table = document.LastSection.AddTable(); table.ResetCells(2,2); IWField hyperlinkField = table[0,1].AddParagraph().AppendHyperlink("https://xxxx.com/", "xxxxx", HyperlinkType.WebLink); ChangeHyperlinkSytle(hyperlinkField); document.Save("output.docx"); document.Close(); Process.Start("output.docx"); |
|
/// <summary> /// Change the background for hyperlink field. /// </summary> /// <param name="hyperlinkField"></param> private void ChangeHyperlinkSytle(IWField hyperlinkField) { WParagraph paragraph = hyperlinkField.OwnerParagraph; foreach (ParagraphItem item in paragraph.ChildEntities) { if (!(item is IWField) && (item is WTextRange)) { (item as WTextRange).CharacterFormat.FontName = "Arial"; (item as WTextRange).CharacterFormat.FontSize = 20; } } } |
|
WordDocument document = new WordDocument(); document.EnsureMinimal(); IWTable table = document.LastSection.AddTable(); table.ResetCells(2,2); IWField hyperlinkField = table[0,1].AddParagraph().AppendHyperlink("https://xxxx.com/", "xxxxx", HyperlinkType.WebLink); ChangeHyperlinkSytle(hyperlinkField); document.Save("output.docx"); document.Close(); Process.Start("output.docx"); |
|
/// <summary> /// Change the background for hyperlink field. /// </summary> /// <param name="hyperlinkField"></param> private void ChangeHyperlinkSytle(IWField hyperlinkField) { WParagraph paragraph = hyperlinkField.OwnerParagraph; foreach (ParagraphItem item in paragraph.ChildEntities) { if (!(item is IWField) && (item is WTextRange)) { (item as WTextRange).CharacterFormat.FontName = "Arial"; (item as WTextRange).CharacterFormat.FontSize = 20; } } } |