Aspose Example
官方使用说明(net)
Aspose dmeo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Aspose.Words;
namespace AsposeDemo
{
class Program
{
static void Main(string[] args)
{
string tempPath = "temp.docx";
string outPath = "new.docx";
var doc = new Document(tempPath);
//数据绑定到表格
string[] fieldName = new string[] {"UserName","Gender","Birthday","Address" };
object[] filedValues = new Object[] { "张三","男","1988-09-02","陕西咸阳"};
doc.MailMerge.Execute(fieldName,filedValues);
//替换书签内容
var bookmark1 = doc.Range.Bookmarks["bookmark1"];
bookmark1.Text = "test bookmark";
//查找替换
doc.Range.Replace("myname","刘尚鑫",false,true);
doc.Save(outPath);
Console.WriteLine("OK");
Console.ReadKey();
}
}
}