Aspose Example

官方使用说明(net)

http://www.aspose.com/docs/display/wordsnet/Find+and+Replace+Overview#FindandReplaceOverview-replace1

 

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();

        }

    }

}

Aspose Example,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。