解决用Aspose.Words,在word文档中创建表格的实现方法
更新时间:2013年05月20日 09:38:57 作者:
本篇文章是对利用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");
复制代码 代码如下:
//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");
相关文章
C#实现PDF签名时添加时间戳的2种方法(附VB.NET代码)
在PDF添加签名时,支持添加可信时间戳来保证文档的法律效应。本文,将通过C#程序代码介绍如何添加可信时间戳,可通过2种方法来实现。感兴趣的可以了解一下2021-05-05
最新评论