如何在 table 中插入标题并在 aspose.word 中插入图形

how to insert caption to table and figure in aspose.word

我想创建一个 table 的图形和 table 的 table,但首先 table 和图形的标题应该是 Identify.and我需要在 tables 和图

中插入标题

请尝试使用以下代码。

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 工作,担任开发人员推广员。