How to set different border width for table border and cell border respectively

Hi,

I want to set different border width for table border and cell border respectively through below methods:

// to set table border width, it seems like the setting does not work
docBuilder.getRowFormat().getBorders().setLineWidth(10);
/*docBuilder.getRowFormat().getBorders().getBottom().setLineWidth(10);
docBuilder.getRowFormat().getBorders().getLeft().setLineWidth(10);
docBuilder.getRowFormat().getBorders().getRight().setLineWidth(10);
docBuilder.getRowFormat().getBorders().getTop().setLineWidth(10);*/

docBuilder.getCellFormat().getBorders().setLineWidth(2);

But it seems like the above code can not work well, only the cell width can be set correctly. No matter which value was set to table border width, the width keep 1 always. Are there any ways can be used to set different width for table border and its cell border?

Thanks.

Please reference below sample code:

DocumentBuilder docBuilder = new DocumentBuilder();
com.aspose.words.Style style = docBuilder.getDocument().getStyles().get("Normal");
if (style != null)
{
    docBuilder.getParagraphFormat().setStyle(style);
}

docBuilder.clearRunAttrs();
// begin table
docBuilder.startTable();
docBuilder.getParagraphFormat().clearFormatting();
docBuilder.getCellFormat().clearFormatting();
docBuilder.getRowFormat().clearFormatting();

// to set table border width, it seems like the setting does not work
docBuilder.getRowFormat().getBorders().setLineWidth(10);
/*docBuilder.getRowFormat().getBorders().getBottom().setLineWidth(10);
docBuilder.getRowFormat().getBorders().getLeft().setLineWidth(10);
docBuilder.getRowFormat().getBorders().getRight().setLineWidth(10);
docBuilder.getRowFormat().getBorders().getTop().setLineWidth(10);*/

// The first row
docBuilder.getRowFormat().setHeight(0);
docBuilder.getRowFormat().setAllowAutoFit(true);

// The first cell
docBuilder.insertCell();
docBuilder.getCellFormat().clearFormatting();
docBuilder.getCellFormat().getBorders().setColor(Color.black);
docBuilder.getCellFormat().getBorders().setLineStyle(LineStyle.SINGLE);
docBuilder.getCellFormat().getBorders().setLineWidth(2);
docBuilder.getParagraphFormat().clearFormatting();
docBuilder.write("111");

// The second cell
docBuilder.insertCell();
docBuilder.getCellFormat().clearFormatting();
docBuilder.getCellFormat().getBorders().setColor(Color.black);

docBuilder.getCellFormat().getBorders().setLineStyle(LineStyle.SINGLE);
docBuilder.getCellFormat().getBorders().setLineWidth(2);
docBuilder.getParagraphFormat().clearFormatting();
docBuilder.write("222");

// End the first row
docBuilder.endRow();

// The second row
docBuilder.getRowFormat().setHeight(0);
docBuilder.getRowFormat().setAllowAutoFit(true);

// The 3rd cell
docBuilder.insertCell();
docBuilder.getCellFormat().clearFormatting();
docBuilder.getCellFormat().getBorders().setColor(Color.black);
docBuilder.getCellFormat().getBorders().setLineStyle(LineStyle.SINGLE);
docBuilder.getCellFormat().getBorders().setLineWidth(2);
docBuilder.getParagraphFormat().clearFormatting();
docBuilder.write("333");

// The fourth cell
docBuilder.insertCell();
docBuilder.getCellFormat().clearFormatting();
docBuilder.getCellFormat().getBorders().setColor(Color.black);
docBuilder.getCellFormat().getBorders().setLineStyle(LineStyle.SINGLE);
docBuilder.getParagraphFormat().clearFormatting();
docBuilder.write("444");

// End the second row
docBuilder.endRow();

// end table
docBuilder.endTable();

docBuilder.getDocument().save("c:\testtable.doc");

Hi
Thanks for your request. Could you please create and attach the expected result. I will check the issue and provide you more information.
Best regards,

Hi,

Please see my attachement.

The table boder width is 10, and cell border width is 2.

And I highlight the border color with green.

Thanks.

Hi
Thank you for additional information. The problem occurs, because you set borders of the row, but not border of table. Unfortunately, there is no way to specify border around a table at the moment. I linked your request to the appropriate issue, you will be notified as soon as it is resolved.
As a workaround, you can try using the code provided in the following thread:
Hope this helps.
Best regards.

The issues you have found earlier (filed as WORDSNET-581) have been fixed in this .NET update and in this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(19)