Set Bottom Top Left Right Padding Values for Table Cells in Word Document using Java | Table Style & Default Cell Margins

Using: Aspose.Word JAVA 20.9

Issue similar to How to get or set Cell Vertical Alignment with TableStyle using Java but with Table Cell Margins.

TableStyle object always contains 0.0 values for bottomPadding / topPadding / leftPadding / rightPadding values.

Attaching compressed file which contains: DOCX file with custom created table style Custom table style 1. It contains property for default cell margins - 0.1 each.
Also attaching code snippet for checking if table style margins are correctly applied.

@PROCUREMENT2,

I am afraid, we do not see any attachments in this forum thread. Please ZIP and attach the following resources here for testing:

  • Simplified input DOCX Word document containing the custom table style
  • Please also create a standalone simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing. Please do not include Aspose.Words JAR files in it to reduce the file size.

As soon as you get these pieces of information ready, we will start investigation into your particular scenario/issue and provide you more information.

@awais.hafeez Pardon for inconvenience.
Attaching compressed file, mentioned before.

table_style_cell_margins_not_imported.zip (10.2 KB)

@PROCUREMENT2,

In this case, you can determine the padding / margin values of all the Table Cells by using the following Java code:

Document doc = new Document("C:\\table_style_cell_margins_not_imported\\table_style_custom_margins.docx");

Table table = doc.getFirstSection().getBody().getTables().get(0);
for (Row row : table.getRows()) {
    for (Cell cell : row.getCells()) {
        System.out.println(
                "LeftPadding: " + ConvertUtil.pointToInch(cell.getCellFormat().getLeftPadding()) +
                ", TopPadding: " + ConvertUtil.pointToInch(cell.getCellFormat().getTopPadding()) +
                ", RightPadding: " + ConvertUtil.pointToInch(cell.getCellFormat().getRightPadding()) +
                ", BottomPadding: " + ConvertUtil.pointToInch(cell.getCellFormat().getBottomPadding()));
    }
}