@SuppressWarnings("deprecation") public CTCols addCleanColIntoCols(CTCols cols, CTCol col) { CTCols newCols = CTCols.Factory.newInstance(); for (CTCol c : cols.getColArray()) { cloneCol(newCols, c); } cloneCol(newCols, col); sortColumns(newCols); CTCol[] colArray = newCols.getColArray(); CTCols returnCols = CTCols.Factory.newInstance(); sweepCleanColumns(returnCols, colArray, col); colArray = returnCols.getColArray(); cols.setColArray(colArray); return returnCols; }
@SuppressWarnings("deprecation") public void cleanColumns() { this.newCols = CTCols.Factory.newInstance(); CTCols aggregateCols = CTCols.Factory.newInstance(); CTCols[] colsArray = worksheet.getColsArray(); assert (colsArray != null); for (CTCols cols : colsArray) { for (CTCol col : cols.getColArray()) { cloneCol(aggregateCols, col); } } sortColumns(aggregateCols); CTCol[] colArray = aggregateCols.getColArray(); sweepCleanColumns(newCols, colArray, null); int i = colsArray.length; for (int y = i - 1; y >= 0; y--) { worksheet.removeCols(y); } worksheet.addNewCols(); worksheet.setColsArray(0, newCols); }
public void testCloneCol() { CTWorksheet worksheet = CTWorksheet.Factory.newInstance(); ColumnHelper helper = new ColumnHelper(worksheet); CTCols cols = CTCols.Factory.newInstance(); CTCol col = CTCol.Factory.newInstance(); col.setMin(2); col.setMax(8); col.setHidden(true); col.setWidth(13.4); CTCol newCol = helper.cloneCol(cols, col); assertEquals(2, newCol.getMin()); assertEquals(8, newCol.getMax()); assertTrue(newCol.getHidden()); assertEquals(13.4, newCol.getWidth(), 0.0); }