Broken Table Borders

Dear Aspose Team,

after updating to Aspose Words from 15.4.0 to 16.1.0 and also 16.2.0 we have problems with wrong table borders if we create tables using the DocumentBuilder.

All our tables now have the default borders (full-grid) and ignore all special borders applied.

For example, if I create a new simple table in an empty document:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToDocumentStart();

Table table = builder.startTable();
builder.insertCell();
// will only clear the borders of the first row
// table.clearBorders();

// this seems to be completely ignored
builder.getCellFormat().getBorders().clearFormatting();
builder.getCellFormat().getBorders().setLineWidth(0);

builder.write("#1");
builder.insertCell();
builder.write("#2");
builder.endRow();
builder.insertCell();
builder.write("#3");
builder.insertCell();
builder.write("#4");
builder.endRow();
builder.insertCell();
builder.write("#5");
builder.insertCell();
builder.write("#6");
builder.endRow();
builder.endTable();

doc.save(…);
I get a table with full grid borders.

If I add
table.clearBorders();
the first row is as expected, but the second row is corrupt again.
If I add also
builder.getRowFormat().clearFormatting();
the first row is also corrupt.

The strange part is, that if I open the doc using LibreOffice instead of Microsoft Word 2010, the table borders seems to be shown correctly.

Thanks, for any help.

Best regards,

Andreas Gerasch

Update:

With the new Aspose versions it seems to be required to set the LineType to NONE, if no border should be drawn.

Therefore

builder.getCellFormat().getBorders().setLineWidth(0);
is not enough and should be replaced/altered by
builder.getCellFormat().getBorders().setLineStyle(LineStyle.NONE);
Can you confirm this behavior change? The last working version we tested was Aspose Word 15.4.0.

Best regards,

Andreas Gerasch

Hi Andreas,


Thanks for your inquiry. Please move “table.clearBorders();” line after the table building code is finished i.e. after “builder.endTable();” line just before the “doc.save(…);” method. Hope, this helps.
Andreas:
Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToDocumentStart();

Table table = builder.startTable();
builder.insertCell();
// will only clear the borders of the first row
// table.clearBorders();

// this seems to be completely ignored
builder.getCellFormat().getBorders().clearFormatting();
builder.getCellFormat().getBorders().setLineWidth(0);

builder.write("#1");
builder.insertCell();
builder.write("#2");
builder.endRow();
builder.insertCell();
builder.write("#3");
builder.insertCell();
builder.write("#4");
builder.endRow();
builder.insertCell();
builder.write("#5");
builder.insertCell();
builder.write("#6");
builder.endRow();
builder.endTable();

table.clearBorders();

doc.save(16.2.0.docx);
Best regards,