Word控件Spire.Doc 【评论】教程(1):在 C#、VB.NET 中插入 Word 注释

文字注释,由用户插入以显示对单词、短语或段落的意见或附加信息,经常出现在文档页边空白处。读者可以根据评论了解更多关于内容的信息或修改内容以更正确或更清楚地表达自己的想法。

Spire.Doc for .NET是一个专业的.NET Word 组件,用于操作Word 文档,使用户能够使用C#、VB.NET 在Word 中插入注释。用户可以直接调用 paragraph.AppendComment(string) 方法为指定段落插入注释。此外,Spire.Doc for .NET 还为用户提供了 Comment 类。用户可以使用此类提供的 Format 属性来设置格式注释。

下面演示了评论可以有多完美。您也可以免费下载 Spire.Doc并进行试用。

插入文字注释

[C#]

using Spire.Doc;using Spire.Doc.Documents;using Spire.Doc.Fields;namespace InsertComment{class Program{static void Main(string[] args){//Load DocumentDocument document = new Document();document.LoadFromFile(@"E:workDocumentsWordDocumentsHumor Them.docx");//Get Paragraph to Insert CommentSection section = document.Sections[0];Paragraph paragraph = section.Paragraphs[2];//Insert Commentstring str = "This paragraph presents the first example to Humor Them.";Comment comment = paragraph.AppendComment(str);comment.Format.Author = "E-iceblue";comment.Format.Initial = "CM";//Save Documentdocument.SaveToFile("comments.docx", FileFormat.Docx2010);System.Diagnostics.Process.Start("comments.docx");}}}

[VB.NET]

Imports Spire.DocImports Spire.Doc.DocumentsImports Spire.Doc.FieldsNamespace InsertCommentClass ProgramPrivate Shared Sub Main(args As String())'Load DocumentDim document As New Document()document.LoadFromFile("E:workDocumentsWordDocumentsHumor Them.docx")'Get Paragraph to Insert CommentDim section As Section = document.Sections(0)Dim paragraph As Paragraph = section.Paragraphs(2)'Insert CommentDim str As String = "This paragraph presents the first example to Humor Them."Dim comment As Comment = paragraph.AppendComment(str)comment.Format.Author = "E-iceblue"comment.Format.Initial = "CM"'Save Documentdocument.SaveToFile("comments.docx", FileFormat.Docx2010)System.Diagnostics.Process.Start("comments.docx")End SubEnd ClassEnd Namespace

Spire.Doc 是一个 Microsoft Word 组件,它使用户能够直接执行范围广泛的 Word 文档处理任务,例如在 WPF、.NET 和 Silverlight 中生成、读取、写入和修改 Word 文档。

以上便是在 C#、VB.NET 中插入 Word 注释,如果您有其他问题也可以继续浏览本系列文章,获取相关教程,你还可以给我留言或者加入我们的官方技术交流群。


欢迎下载|体验更多E-iceblue产品

获取更多信息请咨询在线客服  


标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2022年10月25日
下一篇 2022年10月25日

相关推荐

发表回复

登录后才能评论