如何在aspose.word中向表格和图形插入标题

时间:2017-11-21 11:03:28

标签: c# .net aspose caption aspose.words

我想创建一个图表和表格表格,但是第一个表格和数字应该有标题标识。我需要在表格和图形中插入标题

1 个答案:

答案 0 :(得分:2)

请尝试使用以下代码。

Document doc = new Document(MyDir + "in.docx"); 
DocumentBuilder builder = new DocumentBuilder(doc);

builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;

// Insert caption above the Table
builder.MoveTo(doc.FirstSection.Body.Tables[0].PreviousSibling);
builder.Write("Table: ");
builder.InsertField(@"SEQ Table \* ARABIC", "");

// Insert caption below the Figure
builder.MoveToDocumentEnd();
builder.InsertParagraph();
builder.Write("Figure: ");
builder.InsertField(@"SEQ Figure \* ARABIC", "");

doc.UpdateFields();

doc.Save(MyDir + @"17.11.docx");

我与Aspose一起担任开发者布道者。