翻譯|使用教程|編輯:胡濤|2022-09-16 10:55:53.243|閱讀 168 次
概述:我們將給您介紹如何在 C#、VB.NET 下檢索 Word 中所有 TextRanges 的樣式名稱
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Spire.Doc for .NET是一款專門對 Word 文檔進(jìn)行操作的 .NET 類庫。在于幫助開發(fā)人員無需安裝 Microsoft Word情況下,輕松快捷高效地創(chuàng)建、編輯、轉(zhuǎn)換和打印 Microsoft Word 文檔。擁有近10年專業(yè)開發(fā)經(jīng)驗Spire系列辦公文檔開發(fā)工具,專注于創(chuàng)建、編輯、轉(zhuǎn)換和打印Word/PDF/Excel等格式文件處理,小巧便捷。下面我們將給您介紹如何在 C#、VB.NET 下檢索 Word 中所有 TextRanges 的樣式名稱
Spire.Doc 提供了幾個重載的 Replace 方法來替換不同場景中的文本。本文將向您展示如何使用 Spire.Doc 將模板文檔中的指定文本替換為另一個文檔。
模板文件:
替換文本的文檔:
詳細(xì)步驟:
第 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 document Document document = new Document("Template.docx"); //Load another document to replace text IDocument replaceDocument = new Document("Document1.docx"); //Replace specified text with the other document document.Replace("Document 1", replaceDocument, false, true); //Save the file document.SaveToFile("Output.docx", FileFormat.Docx2013); } } }
以上便是如何在 C#、VB.NET 下檢索 Word 中所有 TextRanges 的樣式名稱,如果您有其他問題也可以繼續(xù)瀏覽本系列文章,獲取相關(guān)教程,你還可以給我留言或者加入我們的官方技術(shù)交流群。
歡迎下載|體驗更多E-iceblue產(chǎn)品
獲取更多信息請咨詢 ;技術(shù)交流Q群(767755948)
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn