VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > c#编程 >
  • C#教程之解决用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");

相关教程