ASF Bugzilla – Attachment 36567 Details for
Bug 62759
removeColumn corrupts XSSFTable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to XSSFTable.removeColumn()
file_62759.txt (text/plain), 3.08 KB, created by
David Gauntt
on 2019-05-04 19:15:53 UTC
(
hide
)
Description:
Patch to XSSFTable.removeColumn()
Filename:
MIME Type:
Creator:
David Gauntt
Created:
2019-05-04 19:15:53 UTC
Size:
3.08 KB
patch
obsolete
> /** > * Remove a column from the table, and shift the remaining cells to the left. > * > * @param columnIndex > * the 0-based position of the column in the table > * @throws IllegalArgumentException > * if no column at the index exists or if the table has only a > * single column > * @since 4.0.0 > */ > public void removeColumn(int columnIndex) { > if (columnIndex < 0 || columnIndex > getColumnCount() - 1) { > throw new IllegalArgumentException("Column index out of bounds"); > } > > if(getColumnCount() == 1) { > throw new IllegalArgumentException("Table must have at least one column"); > } > > final boolean bFixBug62759=true; > > if(bFixBug62759){ > final CellReference from = getStartCellReference(); > final CellReference to = getEndCellReference(); > final int nFirstRow=from.getRow(); > final int nLastRow=to.getRow(); > final int nFirstCol=from.getCol(); > final int nLastCol=to.getCol()-1; > final int nFirstColToShift=nFirstCol+columnIndex+1; > final int nLastColToShift=to.getCol(); > final XSSFSheet sheet=getXSSFSheet(); > > CTTableColumns tableColumns = ctTable.getTableColumns(); > tableColumns.removeTableColumn(columnIndex); > tableColumns.setCount(tableColumns.getTableColumnList().size()); > final AreaReference area = new AreaReference(new CellReference(nFirstRow,nFirstCol), new CellReference(nLastRow,nLastCol), > SpreadsheetVersion.EXCEL2007); > setArea(area); > > /* > * Now shift the cells in the table to the left. This will not affect cells outside the table. > * THIS DOES NOT CHANGE ANY FORMULAE!!! > */ > final String procName="XSSFTable.removeColumn"; > System.out.println(String.format("\n%s: columnIndex=%d nFirstColToShift=%d nLastColToShift=%d", procName,columnIndex,nFirstColToShift,nLastColToShift)); > > if(nFirstColToShift<=nLastColToShift) { > for(int nRow=nFirstRow;nRow<=nLastRow;++nRow) { > final XSSFRow row=sheet.getRow(nRow); > row.shiftCellsLeft(nFirstColToShift,nLastColToShift, 1); > } > } else { > for(int nRow=nFirstRow;nRow<=nLastRow;++nRow) { > final XSSFRow row=sheet.getRow(nRow); > final XSSFCell cell=row.getCell(nLastColToShift); > if(cell!=null) { > row.removeCell(cell); > } > } > } > > } else { > CTTableColumns tableColumns = ctTable.getTableColumns(); > tableColumns.removeTableColumn(columnIndex); > tableColumns.setCount(tableColumns.getTableColumnList().size()); > > } > updateReferences(); > updateHeaders(); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 62759
:
36566
| 36567