Free Support Forum - aspose.com

Remove Borders of a Table

Is it possible to remove the Borders of a table created dynamically ?

Dear Stef,

Hide borders or merge cells?
You can access borders for each cell and make it invisible.
Please check CellBorder.LineFormat.ShowLines property.

Cells merging is not implemented yet.

Alexey,

I need to be able to turn borders on and off on a cell basis. The CellBorder class doesn’t have a lineformat property (at least not in Java) and using the iterator seems to cause an infinite loop. Is there a workaround?

Ken

Dear Ken,

You can set the border on and off for particular PPT table cells using Aspose.Slides for Java. I have shared the code snippet for your reference whereby I have set the top and bottom border. You can use the CellBorder class to access the certain border of a particular cell and can set that on or off.

//Instantiate PresentationEx class that represents PPTX file
Presentation pres = new Presentation();
//Add an empty slide
Slide slide = pres.addEmptySlide();
//Define position, table width, table height, columns and rows

int xPosition = 880;
int yPosition = 1400;
int tableWidth = 4000;
int tableHeight = 500;
int columns = 4;
int rows = 4;
float borderWidth = 2;

//Adding a new table to the slide using specified table parameters
Table table = slide.getShapes().addTable(xPosition, yPosition, tableWidth, tableHeight,
columns, rows, borderWidth, java.awt.Color.BLUE);

//Accessing the bottom border of cell(0,0)
CellBorder bottom= table.getCell (0 , 0).getBorderBottom ();
java.util.Iterator iterator= bottom.iterator();
while (iterator.hasNext())
{
com.aspose.slides.Line line = (com.aspose.slides.Line)(iterator.next ());
line.getLineFormat().setShowLines ( false);
}

//Accessing the top border of cell(0,0)
CellBorder top= table.getCell (0 , 0).getBorderTop ();
iterator= top.iterator();
while (iterator.hasNext())
{
com.aspose.slides.Line line = (com.aspose.slides.Line)(iterator.next ());
line.getLineFormat().setShowLines ( false);
}

//Write PPTX to Disk

pres.write("d:\\Aspose Data\\JavaData\\tableJ.ppt");

Thanks and Regards,