Aspose.Words生成word文件

这篇博客介绍了如何利用Aspose.Words库在Word文档中插入书签的方法,通过鼠标点击文档位置,选择插入菜单,然后选择书签选项进行操作。关键代码未展示。
摘要由CSDN通过智能技术生成
首先设置word模板,可以点击某个单元格插入书签

插入方法:鼠标点击word文件某处,然后   插入--书签 即可

//关键代码如下……………………

        string tmppath = Server.MapPath("~/Template.doc");

        Document doc = new Document(tmppath); //载入模板

        //使用书签
        if (doc.Range.Bookmarks["mark"] != null)
        {
            //Bookmark mark = doc.Range.Bookmarks["mark"];//根据书签名称获取书签
            //mark.Text = "sean";
        }
        //不使用书签  通过移动单元格 来添加值
        DocumentBuilder builder = new DocumentBuilder(doc);
        //设置单元格内容对齐方式
        builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
        builder.MoveToCell(0, 2, 3,0); //tableIndex,rowIndex,columnIndex,characterIndex  初始索引0
        builder.Write("chang");
        doc.Save("demo.doc", SaveFormat.Doc, SaveType.OpenInWord, Response);  //保存为doc,并打开
       //doc.Save(HttpContext.Current.Server.MapPath
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值