public class ColumnCollection
Example:
//Instantiating a Workbook object Workbook workbook = new Workbook(); //Obtaining the reference of the first worksheet Worksheet worksheet = workbook.getWorksheets().get(0); //Add new Style to Workbook Style style = workbook.createStyle(); //Setting the background color to Blue style.setForegroundColor(Color.getBlue()); //setting Background Pattern style.setPattern(BackgroundType.SOLID); //New Style Flag StyleFlag styleFlag = new StyleFlag(); //Set All Styles styleFlag.setAll(true); //Change the default width of first ten columns for (int i = 0; i < 10; i++) { worksheet.getCells().getColumns().get(i).setWidth(20); } //Get the Column with non default formatting ColumnCollection columns = worksheet.getCells().getColumns(); for (Column column : (Iterable<Column>) columns) { //Apply Style to first ten Columns column.applyStyle(style, styleFlag); } //Saving the Excel file workbook.save("D:\\book1.xls");
Property Getters/Setters Summary | ||
---|---|---|
int | getCount() | |
Column | get(int columnIndex) | |
Gets a object by column index. The Column object of given column index will be instantiated if it does not exist before.
|
Method Summary | ||
---|---|---|
int | add(java.lang.Object value) | |
Reserved for internal use. |
||
void | clear() | |
boolean | contains(java.lang.Object value) | |
Reserved for internal use. |
||
Column | getByIndex(int index) | |
Gets the column object by the index.
|
||
Column | getColumnByIndex(int index) | |
Gets the |
||
int | indexOf(java.lang.Object value) | |
Reserved for internal use. |
||
java.util.Iterator | iterator() | |
void | removeAt(int index) | |
public int getCount()
public Column get(int columnIndex)
public Column getByIndex(int index)
index
- public Column getColumnByIndex(int index)
index
- The position in the list.public void clear()
public void removeAt(int index)
public java.util.Iterator iterator()
public boolean contains(java.lang.Object value)
public int add(java.lang.Object value)
public int indexOf(java.lang.Object value)