Hi Andi,
Please consider my attempt to revert the addRow method to its behaviour
prior to 4.1.2, where I broke it, in my pull request
https://github.com/apache/poi/pull/221
I must admit that the underlying handling of the table grid kind of
escapes the mind focus when I try to reason about rows and cells.
Sorry for all the inconveniences,
Alain
Je 2021-01-19 01:26, Andreas Beeker skribis:
Hi Alain,
please review revision 1875901.
I think it would be better to not add the cells in XSLFTable.initializeRow, as this changes a lot the way how the tables were used up till now.
So basically there are two modes in which to look at the tables:
* generating them from the scratch: so you would add each row and each cell
explicitly like one would generate html tables
* adding a cell to an existing row like in Excel, where the cells of the surrounding rows need to be filled accordingly
I think the second operation could be provided more explicitly and not via a call to XSLFTableRow.addCell, i.e. there's too much "magic" involved for me.
Although I've fixed the growing table grid locally [1] this dependents on the above decision.
Best wishes,
Andi
[1] XSLFSheet ...:
@Override
public XSLFTable createTable(int numRows, int numCols){
if (numRows < 1 || numCols < 1) {
throw new IllegalArgumentException("numRows and numCols must be greater than
0");
}
XSLFTable sh = getDrawing().createTable();
getShapes().add(sh);
sh.setParent(this);
for (int r=0; r<numRows; r++) {
XSLFTableRow row = sh.addRow();
if (r==0) {
for (int c = 0; c < numCols; c++) {
row.addCell();
}
}
}
return sh;
}