【问题标题】:how to insert caption to table and figure in aspose.word如何在 aspose.word 中向表格和图形插入标题
【发布时间】:2017-11-21 11:03:28
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

    请尝试使用以下代码。

    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 合作,担任开发人员宣传员。

    【讨论】:

    • 非常感谢,但 System.ArgumentNullException 发生在“builder.MoveTo(doc.FirstSection.Body.Tables[0].PreviousSibling);”上
    • 请压缩并上传您的 输入 Word 文档和 预期 Word 文档,在 Dropbox 上显示最终结果,并在此处分享下载链接以供测试。您可以使用 MS Word 创建预期的 Word 文档供我们参考。我与 Aspose 一起担任开发人员宣传员。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多