mirror of https://github.com/apache/poi.git
Fix addition and removal of columns in XSLTTable
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1870523 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
557b67cb24
commit
da5d7d44d5
|
@ -179,6 +179,9 @@ public class XSLFTable extends XSLFGraphicFrame implements Iterable<XSLFTableRow
|
||||||
long width = _table.getTblGrid().getGridColArray(_table.getTblGrid().sizeOfGridColArray() - 1).getW();
|
long width = _table.getTblGrid().getGridColArray(_table.getTblGrid().sizeOfGridColArray() - 1).getW();
|
||||||
CTTableCol col = _table.getTblGrid().addNewGridCol();
|
CTTableCol col = _table.getTblGrid().addNewGridCol();
|
||||||
col.setW(width);
|
col.setW(width);
|
||||||
|
for(CTTableRow row : _table.getTrList()) {
|
||||||
|
row.addNewTc();
|
||||||
|
}
|
||||||
updateRowColIndexes();
|
updateRowColIndexes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +197,9 @@ public class XSLFTable extends XSLFGraphicFrame implements Iterable<XSLFTableRow
|
||||||
long width = _table.getTblGrid().getGridColArray(colIdx).getW();
|
long width = _table.getTblGrid().getGridColArray(colIdx).getW();
|
||||||
CTTableCol col = _table.getTblGrid().insertNewGridCol(colIdx);
|
CTTableCol col = _table.getTblGrid().insertNewGridCol(colIdx);
|
||||||
col.setW(width);
|
col.setW(width);
|
||||||
|
for(CTTableRow row : _table.getTrList()) {
|
||||||
|
row.insertNewTc(colIdx);
|
||||||
|
}
|
||||||
updateRowColIndexes();
|
updateRowColIndexes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +210,9 @@ public class XSLFTable extends XSLFGraphicFrame implements Iterable<XSLFTableRow
|
||||||
*/
|
*/
|
||||||
public void removeColumn(int colIdx) {
|
public void removeColumn(int colIdx) {
|
||||||
_table.getTblGrid().removeGridCol(colIdx);
|
_table.getTblGrid().removeGridCol(colIdx);
|
||||||
|
for(CTTableRow row : _table.getTrList()) {
|
||||||
|
row.removeTc(colIdx);
|
||||||
|
}
|
||||||
updateRowColIndexes();
|
updateRowColIndexes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ public class TestXSLFTable {
|
||||||
tab.insertColumn(0);
|
tab.insertColumn(0);
|
||||||
assertEquals(tab.getColumnWidth(1), tab.getColumnWidth(0), 0.00001);
|
assertEquals(tab.getColumnWidth(1), tab.getColumnWidth(0), 0.00001);
|
||||||
tab.addColumn();
|
tab.addColumn();
|
||||||
|
tab.getCell(0, data[0].length + 1);
|
||||||
assertEquals(tab.getColumnWidth(tab.getNumberOfColumns() - 2), tab.getColumnWidth(tab.getNumberOfColumns() - 1), 0.00001);
|
assertEquals(tab.getColumnWidth(tab.getNumberOfColumns() - 2), tab.getColumnWidth(tab.getNumberOfColumns() - 1), 0.00001);
|
||||||
tab.removeColumn(0);
|
tab.removeColumn(0);
|
||||||
tab.removeColumn(tab.getNumberOfColumns() - 1);
|
tab.removeColumn(tab.getNumberOfColumns() - 1);
|
||||||
|
|
Loading…
Reference in New Issue