Properties of RowFormat doesn't work properly

It seems that using of properties of RowFormat doesn’t work properly.
I want to format a table using following properties.

In VBA it looks like this:

With Selection.Tables(1)
    .TopPadding = CentimetersToPoints(0)
    .BottomPadding = CentimetersToPoints(0)
    .LeftPadding = CentimetersToPoints(0.12)
    .RightPadding = CentimetersToPoints(0.12)
    .Spacing = 0
    .AllowPageBreaks = True
    .AllowAutoFit = False
End With

Here is the corresponding code using Aspose:

row.getRowFormat().setAllowAutoFit(false);
row.getRowFormat().setAllowBreakAcrossPages(false);
row.getRowFormat().setTopPadding(0 d);
row.getRowFormat().setBottomPadding(0 d);
row.getRowFormat().setLeftPadding(ConvertUtil.millimeterToPoint(1.2 d));
row.getRowFormat().setRightPadding(ConvertUtil.millimeterToPoint(1.2 d));
row.getRowFormat().setCellSpacing(0 d);

It seems that none of these properties is set. For exmaple AllowAutoFit is true, left and right padding is set to default size of 19mm.

Thanks a lot.

Sincerely,
Matthias Schlosser

Addendum: See complete code for creating table in attachement’ testTable.txt’

Hi

Thanks for your inquiry. As I can see, in your code, you use both DocumentBuilder and DOM approaches. I suppose, you should chose one of them. I modified your code and it seems all works fine:

DocumentBuilder builder = new DocumentBuilder();
Table table = builder.startTable();
for (int y = 0; y <3; y++)
{
    Row row = new Row(builder.getDocument().getDocument());
    builder.getRowFormat().setHeadingFormat(y == 0);
    builder.getRowFormat().setAllowAutoFit(false);
    builder.getRowFormat().setAllowBreakAcrossPages(false);
    builder.getRowFormat().setTopPadding(0 d);
    builder.getRowFormat().setBottomPadding(0 d);
    builder.getRowFormat().setLeftPadding(ConvertUtil.millimeterToPoint(1.2 d));
    builder.getRowFormat().setRightPadding(ConvertUtil.millimeterToPoint(1.2 d));
    builder.getRowFormat().setCellSpacing(0 d);
    System.out.println(ConvertUtil.millimeterToPoint(1.2 d));
    for (int x = 0; x <8; x++)
    {
        builder.getCellFormat().setWidth(0.4 * 72 + x * 10); //0.4"
        if (y == 0)
        {
            builder.write("Title");
        }
        else
        {
            builder.getFont().setItalic(true);
            builder.getFont().setSize(10 d);
            builder.write("RUN1");
            builder.getFont().clearFormatting();
            builder.getFont().setBold(true);
            builder.getFont().setSize(7 d);
            builder.write("RUN2");
            builder.getFont().clearFormatting();
            builder.getFont().setUnderline(Underline.DOT_DASH_HEAVY);
            builder.getFont().setSize(7 d);
            builder.write("RUN3");
            // This alternatives cell backgrounds.
            boolean isBlack = (((x + y) & 0x01) != 0);
            builder.getCellFormat().getShading().setBackgroundPatternColor((isBlack) ? new Color(144, 238, 144) : new Color(255, 255, 224));
        }
    }
    builder.endRow();
}
builder.endTable();
builder.getDocument().save("C:\\Temp\\out.doc");

Hope this helps.
Best regards

Perfect, it works fine!
Thanks a lot.

Sincerely,
Matthias Schlosser