C# VB.NET *** 作Word批注(一)—— 插入、修改、删除Word批注

C# VB.NET *** 作Word批注(一)—— 插入、修改、删除Word批注,第1张

概述批注内容可以是对某段文字或内容的注释,也可以是对文段中心思想的概括提要,或者是对文章内容的评判、疑问,以及在阅读时给自己或他人起到提示作用。本篇文章中将介绍如何在C#中 *** 作Word批注,主要包含以下要

批注内容可以是对某段文字或内容的注释,也可以是对文段中心思想的概括提要,或者是对文章内容的评判、疑问,以及在阅读时给自己或他人起到提示作用。本篇文章中将介绍如何在C#中 *** 作Word批注,主要包含以下要点:

插入Word批注修改Word批注删除Word批注

使用工具:Free Spire.Doc for .NET 6.3(最新社区版)

注:编辑代码前注意添加引用SprIE.Doc.dll(dll文件可在安装路径下的Bin文件夹中获取)

1.插入Word批注

C#

using Spire.Doc; Spire.Doc.documents; Spire.Doc.FIElds;namespace InsertComment_Word{    class Program    {        static voID Main(string[] args)        {             //实例化一个document类对象,并加载Word文档            document document = new document();            document.LoadFromfile("sample.docx");            获取第一段第一节            Section section = document.Sections[0];            Paragraph paragraph = section.Paragraphs[];            添加文本到批注            string str = This paragraph describes the origin and the purpose of WEF;            Comment comment = paragraph.AppendComment(str);            添加批注作者            comment.Format.Author = E-iceblue;                      保存并打开文档            document.Savetofile(Comments.docx,fileFormat.Docx2010);            System.Diagnostics.Process.Start();        }    }}

VB.NET

imports Spire.Doc Spire.Doc.documents Spire.Doc.FIEldsnamespace InsertComment_Word        Class Program                Private Shared Sub Main(ByVal args() As String)            '实例化一个document类对象,并加载Word文档            Dim document As document = New document            document.LoadFromfile(获取第一段第一节            Dim section As Section = document.Sections(Dim paragraph As Paragraph = section.Paragraphs(Dim str String = "            Dim comment As Comment = paragraph.AppendComment(str)        End Sub    End ClassEnd namespace

 

测试结果:

2.修改、删除批注

测试文档:

C#

 Spire.Doc; ReplaceAndRemoveComment_Word{    [] args)        {            初始化document类实例,加载带有批注的Word文档            document document = test.docx修改第一个批注内容            document.Comments[0].Body.Paragraphs[0].Replace(",What is the WEF ?false,1)">false移除第二个批注            document.Comments.RemoveAt(1RemoveAndReplace.docx);        }    }}

 

VB.NET

 Spire.Doc ReplaceAndRemoveComment_Word        初始化document类实例,加载带有批注的Word文档            修改第一个批注内容            document.Comments(0).Body.Paragraphs(0).Replace(End namespace

 

测试结果:

以上是本次关于 *** 作Word批注的全部内容。感谢浏览!

总结

以上是内存溢出为你收集整理的C# /VB.NET *** 作Word批注(一)—— 插入、修改、删除Word批注全部内容,希望文章能够帮你解决C# /VB.NET *** 作Word批注(一)—— 插入、修改、删除Word批注所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1213387.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存