Hi Anbu,
Thanks for your inquiry. In your document, the table style ‘Light Grid Accent 5’ is applied to table. Please see the attached image for detail. In this case, I suggest you please use the Document.expandTableStylesToDirectFormatting method. This method converts formatting specified in table styles into direct formatting on tables in the document.
Moreover, this method exists because Aspose.Words v 13.6.0 provides only limited support for table styles. This method might be useful when you load a DOCX or WordprocessingML document that contains tables formatted with table styles and you need to query formatting of tables, cells, paragraphs or text.
Document doc = new Document(MyDir + "input.docx");
NodeList<Cell> cellNodes = doc.selectNodes("//Cell");
for (Cell cell : cellNodes)
{
double width = cell.getCellFormat().getBorders().getLeft().getLineWidth();
String color = cell.getCellFormat().getBorders().getTop().getColor().toString();
System.out.println("Width ::" + width);
System.out.println("Color ::" + color);
System.out.println("Background Color ::" + cell.getCellFormat().getShading().getBackgroundPatternColor());
}
System.out.println("------------------------------------------");
// Expand table style formatting to direct formatting.
doc.expandTableStylesToDirectFormatting();
// Now print the cell shading after expanding table styles.
for (Cell cell : cellNodes)
{
double width = cell.getCellFormat().getBorders().getLeft().getLineWidth();
String color = cell.getCellFormat().getBorders().getTop().getColor().toString();
System.out.println("Width ::" + width);
System.out.println("Color ::" + color);
System.out.println("Background Color ::" + cell.getCellFormat().getShading().getBackgroundPatternColor());
}
doc.save(MyDir + "out.docx");
Please read following documentation links for your kind reference.
https://docs.aspose.com/words/java/specifying-table-and-cell-widths/
https://docs.aspose.com/words/java/working-with-tablestyle/
Hope this helps you. Please let us know if you have any more queries.