我们将给您介绍如何在 C#、VB.NET 下检索 Word 中所有 TextRanges 的样式名称
Spire.Doc for .NET是一款专门对 Word 文档进行操作的 .NET 类库。在于帮助开发人员无需安装 Microsoft Word情况下,轻松快捷高效地创建、编辑、转换和打印 Microsoft Word 文档。拥有近10年专业开发经验Spire系列办公文档开发工具,专注于创建、编辑、转换和打印Word/PDF/Excel等格式文件处理,小巧便捷。下面我们将给您介绍如何在 C#、VB.NET 下检索 Word 中所有 TextRanges 的样式名称
Spire.Doc 提供了几个重载的 Replace 方法来替换不同场景中的文本。本文将向您展示如何使用 Spire.Doc 将模板文档中的指定文本替换为另一个文档。
模板文件:
替换文本的文档:
详细步骤:
第 1 步:加载模板文档。
Document document = new Document("Template.docx");
第 2 步:加载另一个文档以替换文本。
IDocument replaceDocument = new Document("Document1.docx");
第 3 步:将指定文本替换为其他文档。
document.Replace("Document 1", replaceDocument, false, true);
第 4 步:保存文件。
document.SaveToFile("Output.docx", FileFormat.Docx2013);
输出:
完整代码:
using Spire.Doc;using Spire.Doc.Interface;namespace Replace_Text_With_Document{class Program{static void Main(string[] args){//Load a template documentDocument document = new Document("Template.docx");//Load another document to replace textIDocument replaceDocument = new Document("Document1.docx");//Replace specified text with the other documentdocument.Replace("Document 1", replaceDocument, false, true);//Save the filedocument.SaveToFile("Output.docx", FileFormat.Docx2013);}}}
以上便是如何在 C#、VB.NET 下检索 Word 中所有 TextRanges 的样式名称,如果您有其他问题也可以继续浏览本系列文章,获取相关教程,你还可以给我留言或者加入我们的官方技术交流群。
欢迎下载|体验更多E-iceblue产品
获取更多信息请咨询在线客服 ;
标签:
来源:慧都
声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!