Right side of cell border dissappears when merging cells in PPTX

Whenever I merge all of cells in a row contained within a .pptx presentation, the right border of the merged cell dissappears. I have even tried to create a function that will re-set all of the cell borders within that row, but the border never shows up:

public static void mergeCells(TableEx table, CellEx start, CellEx end) {
table.mergeCells(start, end, true);

int newRow = start.getFirstRowIndex();
int newCol = start.getFirstColumnIndex();
for (int i=newCol; i<table.getColumns().size(); i++) {
CellEx cell = table.get(i, newRow);
//
// System.out.println(" * SETTING BORDER ON CELL ("+newRow+", “+i+”)");
//
cell.getBorderTop().getFillFormat().setFillType(FillTypeEx.SOLID);
cell.getBorderTop().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
cell.getBorderTop().setWidth(3);

cell.getBorderBottom().getFillFormat().setFillType(FillTypeEx.SOLID);
cell.getBorderBottom().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
cell.getBorderBottom().setWidth(3);

cell.getBorderRight().getFillFormat().setFillType(FillTypeEx.SOLID);
cell.getBorderRight().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
cell.getBorderRight().setWidth(3);

cell.getBorderLeft().getFillFormat().setFillType(FillTypeEx.SOLID);
cell.getBorderLeft().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
cell.getBorderLeft().setWidth(3);
}
}

What is going on here? How do I get my borders back on the merged cell?

Hello Dear,

I have worked with the code snippet shared by you. The issue is that you are merging the cells earlier than setting the borders for individual cells. The issue is that when you merge the cells the reference to cells gets changed. When you try to apply the properties on the cells that have been used in merging the properties doesn’t apply as those references are nonexistent. It’s better to apply properties on cells first and then merge them. For your kind reference, I have shared the modified code snippet. Please also visit this link for reference.

PresentationEx pres = new PresentationEx();

//Access first slide

SlideEx sld = pres.getSlides().get(0);

//Define columns with widths and rows with heights

double[] dblCols = { 50,50,50,50 };

double[] dblRows = { 50,30,30,30,30 };

//Add table shape to slide

int idx = sld.getShapes().addTable(100, 50, dblCols, dblRows);

TableEx tbl = (TableEx)sld.getShapes().get(idx);

CellEx start=tbl.get(0, 1);

CellEx end=tbl.get(3, 1);

int newRow = start.getFirstRowIndex();

int newCol = start.getFirstColumnIndex();

int i ;

for ( i = newCol; i < tbl.getColumns().size(); i++)

{

CellEx cell = tbl.get(i, newRow);

//

// System.out.println(" * SETTING BORDER ON CELL (“+newRow+”, “+i+”)");

//

cell.getBorderTop().getFillFormat().setFillType(FillTypeEx.SOLID);

cell.getBorderTop().getFillFormat().getSolidFillColor().setColor(java.awt.Color.BLACK);

cell.getBorderTop().setWidth(3);

cell.getBorderBottom().getFillFormat().setFillType(FillTypeEx.SOLID);

cell.getBorderBottom().getFillFormat().getSolidFillColor().setColor(java.awt.Color.BLACK);

cell.getBorderBottom().setWidth(3);

cell.getBorderRight().getFillFormat().setFillType(FillTypeEx.SOLID);

cell.getBorderRight().getFillFormat().getSolidFillColor().setColor(java.awt.Color.BLACK);

cell.getBorderRight().setWidth(3);

cell.getBorderLeft().getFillFormat().setFillType(FillTypeEx.SOLID);

cell.getBorderLeft().getFillFormat().getSolidFillColor().setColor(java.awt.Color.BLACK);

cell.getBorderLeft().setWidth(3);

}

//Merge cells 1 & 2 of row 1

tbl.mergeCells(start, end, false);

//Add text to the merged cell

tbl.get(0,0).getTextFrame().setText(“Merged Cells”);

//Write PPTX to Disk

pres.write(“d:\Aspose Data\tableJ.pptx”);

Thanks and Regards,

I have tried setting border styles before merging cells and I am still observing that the right border is not being drawn. Here is my code:

public static void mergeCells(TableEx table, CellEx start, CellEx end) {
int newRow = start.getFirstRowIndex();
int newCol = start.getFirstColumnIndex();
for (int i=newCol; i<table.getColumns().size(); i++) {
CellEx cell = table.get(i, newRow);

// System.out.println(" * SETTING BORDER ON CELL ("+newRow+", “+i+”)");

cell.getBorderTop().getFillFormat().setFillType(FillTypeEx.SOLID);
cell.getBorderTop().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
cell.getBorderTop().setWidth(1);

cell.getBorderBottom().getFillFormat().setFillType(FillTypeEx.SOLID);
cell.getBorderBottom().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
cell.getBorderBottom().setWidth(1);

cell.getBorderRight().getFillFormat().setFillType(FillTypeEx.SOLID);
cell.getBorderRight().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
cell.getBorderRight().setWidth(1);

cell.getBorderLeft().getFillFormat().setFillType(FillTypeEx.SOLID);
cell.getBorderLeft().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
cell.getBorderLeft().setWidth(1);
}

table.mergeCells(start, end, true);
}

Here is an example of my result:

Hello Dear,

I have observed the code snippet shared by you. I feel you may have referenced my code snippet for your application. In order to further investigate and resolve the issue, I would request you to please share the source presentation for which you are experiencing issue along with the complete project code snippet. I appreciate you cooperation in advance for that.

Thanks and Regards,