当前位置: 移动技术网 > IT编程>开发语言>c# > 解决用Aspose.Words,在word文档中创建表格的实现方法

解决用Aspose.Words,在word文档中创建表格的实现方法

2019年07月18日  | 移动技术网IT编程  | 我要评论
代码如下所示:
复制代码 代码如下:

  //open document and create documentbuilder
  aspose.words.document doc = new aspose.words.document("demo.doc");
  documentbuilder builder = new documentbuilder(doc);
  //set table formating
  //set borders
  builder.cellformat.borders.linestyle = linestyle.single;
  builder.cellformat.borders.color = color.red;
  //set left indent
  builder.rowformat.leftindent = 100;
  // etc...
  //move documentbuilder cursor to the bookmark
  builder.movetobookmark("mybookmark");
  //insert some table
  for (int i = 0; i < 5; i++)
  {
       for (int j = 0; j < 5; j++)
       {
            builder.insertcell();
            builder.write("this is cell");
       }
       builder.endrow();
  }
  builder.endtable();
  //save output document
  doc.save("demo2.doc");

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网