彩票走势图

logo Aspose中文文档

插入表格


Aspose.Words是一种高级Word文档处理API,用于执行各种文档管理和操作任务。API支持生成,修改,转换,呈现和打印文档,而无需在跨平台应用程序中直接使用Microsoft Word。

Aspose API支持流行文件格式处理,并允许将各类文档导出或转换为固定布局文件格式和最常用的图像/多媒体格式。

Aspose.Words for .NET 最新下载

VSTO
Word.Application wordApp = Application;
wordApp.Documents.Open("Inserting Table.doc");
CreateDocumentPropertyTable();
this.Application.ActiveDocument.Save();
private void CreateDocumentPropertyTable()
{
object start = 0, end = 0;
Word.Range rng = this.Application.ActiveDocument.Range(ref start, ref end);

// Insert a title for the table and paragraph marks.
rng.InsertBefore("Document Statistics");
rng.Font.Name = "Verdana";
rng.Font.Size = 16;
rng.InsertParagraphAfter();
rng.InsertParagraphAfter();
rng.SetRange(rng.End, rng.End);

// Add the table.
rng.Tables.Add(this.Application.ActiveDocument.Paragraphs[2].Range, 3, 2, ref missing, ref missing);

// Format the table and apply a style.
Word.Table tbl = this.Application.ActiveDocument.Tables[1];
tbl.Range.Font.Size = 12;
tbl.Columns.DistributeWidth();
object styleName = "Table Professional";
tbl.set_Style(ref styleName);

// Insert document properties into cells.
tbl.Cell(1, 1).Range.Text = "Document Property";
tbl.Cell(1, 2).Range.Text = "Value";
tbl.Cell(2, 1).Range.Text = "Subject";
tbl.Cell(2, 2).Range.Text = ((Office.DocumentProperties)(this.Application.ActiveDocument.BuiltInDocumentProperties))
[Word.WdBuiltInProperty.wdPropertySubject].Value.ToString();
tbl.Cell(3, 1).Range.Text = "Author";
tbl.Cell(3, 2).Range.Text = ((Office.DocumentProperties)(this.Application.ActiveDocument.BuiltInDocumentProperties))
[Word.WdBuiltInProperty.wdPropertyAuthor].Value.ToString();
}

点击复制

Aspose.Words

Document doc = new Document("Inserting Table.doc");
DocumentBuilder builder = new DocumentBuilder(doc);

// We call this method to start building the table.
builder.StartTable();
builder.InsertCell();
builder.Write("Row 1, Cell 1 Content.");

// Build the second cell
builder.InsertCell();
builder.Write("Row 1, Cell 2 Content.");

// Call the following method to end the row and start a new row.
builder.EndRow();

// Build the first cell of the second row.
builder.InsertCell();
builder.Write("Row 2, Cell 1 Content");

// Build the second cell.
builder.InsertCell();
builder.Write("Row 2, Cell 2 Content.");
builder.EndRow();

// Signal that we have finished building the table.
builder.EndTable();

// Save the document to disk.
doc.Save("Inserting Table.doc");

点击复制

下载示例代码

  •  
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP