Spire.Doc for .NET是一款专门对 Word 文档进行操作的 .NET 类库。在于帮助开发人员无需安装 Microsoft Word情况下,轻松快捷高效地创建、编辑、转换和打印 Microsoft Word 文档。拥有近10年专业开发经验Spire系列办公文档开发工具,专注于创建、编辑、转换和打印Word/PDF/Excel等格式文件处理,小巧便捷。
Spire.Doc for.NET 最新下载(qun:767755948)https://www.evget.com/product/3368/download
在 Word 2013 及更高版本中,您可以回复批注,以便更轻松地了解整个对话。Spire.Doc 还允许程序员通过 ReplyToComment 方法插入评论作为对所选评论的回复。
第 1 步:创建一个 Document 对象并加载一个包含评论的 Word 文档。
Document doc = new Document(); doc.LoadFromFile("Comment.docx");
第 2 步:获取第一条评论。
Comment comment = doc.Comments[0];
第 3 步:创建新评论并指定作者和内容。
Comment replyComment = new Comment(doc); replyComment.Format.Author = "Adam"; replyComment.Body.AddParagraph().AppendText("Exactly.");
第 4 步:将新评论添加为对所选评论的回复。
comment.ReplyToComment(replyComment);
第 5 步:保存到文件。
doc.SaveToFile("ReplyToComment.docx", FileFormat.Docx2013);
完整代码:
[C#]
using Spire.Doc; using Spire.Doc.Fields; namespace ReplyComment { class Program { static void Main(string[] args) { Document doc = new Document(); doc.LoadFromFile("Comment.docx"); Comment comment = doc.Comments[0]; Comment replyComment = new Comment(doc); replyComment.Format.Author = "Adam"; replyComment.Body.AddParagraph().AppendText("Exactly."); comment.ReplyToComment(replyComment); doc.SaveToFile("ReplyToComment.docx", FileFormat.Docx2013); } } }
[VB.NET]
Imports Spire.Doc Imports Spire.Doc.Fields Namespace ReplyComment Class Program Private Shared Sub Main(args As String()) Dim doc As New Document() doc.LoadFromFile("Comment.docx") Dim comment As Comment = doc.Comments(0) Dim replyComment As New Comment(doc) replyComment.Format.Author = "Adam" replyComment.Body.AddParagraph().AppendText("Exactly.") comment.ReplyToComment(replyComment) doc.SaveToFile("ReplyToComment.docx", FileFormat.Docx2013) End Sub End Class End Namespace
以上便是在C#、VB.NET如何在Word的评论中插入图片,如果您有其他问题也可以继续浏览本系列文章,获取相关教程,你还可以给我留言或者加入我们的官方技术交流群。