public class ColumnCollection extends CollectionBase
Column objects that represent the individual column(setting)s in a worksheet.
The Column object only represents the settings such as column width, styles, .etc. for the whole column,
has nothing to do with the fact that there are non-empty cells(data) or not in corresponding column.
And the "Count" of this collection only represents the count Column objects that have been instantiated in this collection,
has nothing to do with the fact that there are non-empty cells(data) or not in the worksheet.
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 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("book1.xls");
| Modifier and Type | Method and Description |
|---|---|
Column |
get(int columnIndex)
Gets a
Column object by column index. |
Column |
getByIndex(int index)
Deprecated.
Use Columns.GetColumnByIndex() method instead.
|
Column |
getColumnByIndex(int index)
Gets the
Column object by the position in the list. |
public Column getByIndex(int index)
Remarks
NOTE: This member is now obsolete. Instead, please use Columns.GetColumnByIndex() method. This property will be removed 12 months later since June 2010. Aspose apologizes for any inconvenience you may have experienced.index - public Column getColumnByIndex(int index)
Column object by the position in the list.index - The position in the list.public Column get(int columnIndex)
Column object by column index.
The Column object of given column index will be instantiated if it does not exist before.get in class CollectionBasecolumnIndex - Specified position index.See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.