欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-12-20 18:14:22
代码如下所示:复制代码 代码如下:  //open document and create documentbuilder  aspose.words....
代码如下所示:
复制代码 代码如下:

  //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");

上一篇:

下一篇: