[研究][C#][ASP.NET] 用 Aspose.Words for .NET v20.6.0 取代 .docx 中文字
2020-06-30
Aspose.Words for .NET - Evaluation Version Limitations
評估版的限制:會有浮水印 or 三十天功能限制
產生的 .pdf 內第一行會出現紅字
Evaluation Only. Created with Aspose.Words. Copyright 2003-2020 Aspose Pty Ltd.
NuGet 上 Aspose.Words 授權說明
.NET APIs to Process Word Documents
Aspose.Words for .NET 20.6 Release Notes (Bug 修正列表)
Find and Replace範例
測試工具:Visual Studio 2019 v16.6.2 + ASP.NET + WebForm + WebApplication
NuGet 安裝 Aspose.Words for .NET v20.6.0
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AsposeWordsReplaceText.Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> </div> </form> </body> </html> |
Default.aspx.cs
using Aspose.Words; using Aspose.Words.Replacing; using System; namespace AsposeWordsReplaceText { public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { // https://docs.aspose.com/display/wordsnet/Find+and+Replace string dataDir = @"C:\Temp\"; string fileName = "樣張1.docx"; Document doc = new Document(dataDir + fileName); doc.Range.Replace("{$大學}", "測試大學", new FindReplaceOptions(FindReplaceDirection.Forward)); dataDir = dataDir + "樣張1R.docx"; doc.Save(dataDir); } } } |
對相同、複雜的 "樣張1.docx" 中,可以順利提換文字,不會像 FreeSpire.Doc 7.11.0 和 NPOI 和iText 7失敗。
(完)
沒有留言:
張貼留言