I need help with apache POI lib.
A final version of table should looks like that:
and now I'm able to get this:
From some reason I'm not able to merge this cells on the begin and on the end.
Below is code which is merging cells(position: 1):
private static void mergeVerticalCells(int maxCellPosition, XWPFTableRow restartRow, XWPFTableRow... continueRows) {
for (int i = 0 ; i <= maxCellPosition ; i++) {
CTVMerge vmergeRestart = CTVMerge.Factory.newInstance();
vmergeRestart.setVal(STMerge.RESTART);
restartRow.getCell(i).getCTTc().getTcPr().setVMerge(vmergeRestart);
}
for (XWPFTableRow row : continueRows) {
CTVMerge vmergeContinue = CTVMerge.Factory.newInstance();
vmergeContinue.setVal(STMerge.CONTINUE);
for (int i = 0 ; i<= maxCellPosition ; i++) {
row.getCell(i).getCTTc().getTcPr().setVMerge(vmergeContinue);
}
}
}
Here is link where I found this solution to merge cells
Can somebody show me what I'm doing wrong?