Free Support Forum - aspose.com

Use Table "Title" Property to Insert Table Caption

Can Aspose Words do this: we have a word doc with 1,100+ tables whose “Title” property contains text. We would like to extract that text and use it to insert a table caption for each table. Also need to bold and color fill the first and last rows of each table. Doing this in Word VBA runs more than 24 hours.

Hi there,

Thanks for your inquiry.

Unfortunately, Aspose.Words does not provide API to get/set the “Title” property of table. However, we have already logged this feature request as WORDSNET-5890 in our issue tracking system. You will be notified via this forum thread once this feature is available. We apologize for your inconvenience.

Please use the following code example set the background color of table’s cells and set their text as bold. Hope this helps you.

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

foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
{
    foreach (Cell cell in table.FirstRow.Cells)
    {
        cell.CellFormat.Shading.BackgroundPatternColor = Color.Yellow;

        foreach (Run run in cell.GetChildNodes(NodeType.Run, true))
        {
            run.Font.Bold = true;
        }
    }

    foreach (Cell cell in table.LastRow.Cells)
    {
        cell.CellFormat.Shading.BackgroundPatternColor = Color.Yellow;

        foreach (Run run in cell.GetChildNodes(NodeType.Run, true))
        {
            run.Font.Bold = true;
        }
    }
}
                 
doc.Save(MyDir + "17.6.docx");

@pflick,

The issues you have found earlier (filed as WORDSNET-5890) have been fixed in this Aspose.Words for .NET 18.6 update and this Aspose.Words for Java 18.6 update.