Free Support Forum - aspose.com

How to remove Borders from a Table created using Aspose Words for Java

I was trying out the demo of Aspose Words for Java in my application. In one case, I am creating a very simple table using startTable(), insertcell() methods of the class DocumentBuilder. Now, when the table gets created it automatically lays out a border which is visible in Word Document. What I am trying to achieve is the table that I create will have no visible border. In HTML the code will be :

... I am including here my code snippet so that it looks clear whats actualy going on -

public class DocumentTable

{

private DocumentBuilder builder = new DocumentBuilder();

public void createTableNoBorder() throws Exception

{

builder.getCellFormat().getBorders().clearFormatting();

builder.startTable();

for (int y = 0; y < 8; y++){

builder.insertCell();

builder.write("a"+ y+1);

}

builder.endTable();

}

} // End of class DocumentTable

---------------------------------------------------------------------------------------------------

Now in this code using the line builder.getCellFormat().getBorders().clearFormatting(); I tried to get rid of the border of the table. I even placed this line after builder.startTable(); at the end of the method before/after builder.endTable(); but it simply doesnt work.

So please let me know if there is any solution to this issue. Thanks in advance.

Nafi

Hi

Thanks for your inquiry. Borders are disabled by default. When you open generated document in MS Word you should select “Hide Gridlines” from “Table” menu.

Unfortunately, you can’t hide gridlines using Aspose.Words because “Table / Hide Gridlines” is option of MSWord.

Best regards.