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

本篇文章是对利用Aspose.Words,在word文档中创建表格的实现方法进行了详细的分析介绍,需要的朋友参考下

代码如下所示:
复制代码 代码如下:

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

以上就是解决用Aspose.Words,在word文档中创建表格的实现方法的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » 其他教程