/** * Remove a column from the table. * * @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"); } CTTableColumns tableColumns = ctTable.getTableColumns(); tableColumns.removeTableColumn(columnIndex); tableColumns.setCount(tableColumns.getTableColumnList().size()); updateReferences(); updateHeaders(); }
columns.setCount(columns.sizeOfTableColumnArray());
CTTableColumns ctColumns = ctTable.addNewTableColumns(); CTAutoFilter autofilter = ctTable.addNewAutoFilter(); ctColumns.setCount(table_headers.size()); for(int i = 0; i < table_headers.size(); i++) { CTTableColumn column = ctColumns.addNewTableColumn(); column.setName(table_headers.get(i)); column.setId(i + 1); CTFilterColumn filter = autofilter.addNewFilterColumn(); filter.setColId(i + 1); filter.setShowButton(true); }
/** * Remove a column from the table. * * @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"); } CTTableColumns tableColumns = ctTable.getTableColumns(); tableColumns.removeTableColumn(columnIndex); tableColumns.setCount(tableColumns.getTableColumnList().size()); updateReferences(); updateHeaders(); }
columns.setCount(3L); //define number of columns
ctColumns.setCount(tableHeaders.size());
columns.setCount(columns.sizeOfTableColumnArray());
columns.setCount(3);
columns.setCount(lastColumn - firstColumn + 1);