public class Column
extends java.lang.Object
Example
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
Style style = workbook.createStyle();
//Setting the background color to Blue
style.setBackgroundColor(Color.getBlue());
//Setting the foreground color to Red
style.setForegroundColor(Color.getRed());
//setting Background Pattern
style.setPattern(BackgroundType.DIAGONAL_STRIPE);
//New Style Flag
StyleFlag styleFlag = new StyleFlag();
//Set All Styles
styleFlag.setAll(true);
//Get first Column
Column column = worksheet.getCells().getColumns().get(0);
//Apply Style to first Column
column.applyStyle(style, styleFlag);
//Saving the Excel file
workbook.save("book1.xls");
| Modifier and Type | Method and Description |
|---|---|
void |
applyStyle(Style style,
StyleFlag flag)
Applies formats for a whole column.
|
byte |
getGroupLevel()
Gets the group level of the column.
|
int |
getIndex()
Gets the index of this column.
|
Style |
getStyle()
Gets the style of this column.
|
double |
getWidth()
Gets the column width in unit of characters.
|
boolean |
hasCustomStyle()
Indicates whether this column has custom style settings(different from the default one inherited from workbook).
|
boolean |
isCollapsed()
whether the column is collapsed
|
boolean |
isHidden()
Indicates whether the column is hidden.
|
void |
setCollapsed(boolean value)
whether the column is collapsed
|
void |
setGroupLevel(byte value)
Gets the group level of the column.
|
void |
setHidden(boolean value)
Indicates whether the column is hidden.
|
void |
setStyle(Style style)
Sets the style of this column.
|
void |
setWidth(double value)
Sets the column width in unit of characters.
|
public int getIndex()
public double getWidth()
Remarks
For spreadsheet, column width is measured as the number of characters of the maximum digit width of the numbers 0~9 as rendered in the normal style's font.public void setWidth(double value)
Remarks
For spreadsheet, column width is measured as the number of characters of the maximum digit width of the numbers 0~9 as rendered in the normal style's font.public byte getGroupLevel()
public void setGroupLevel(byte value)
public boolean isHidden()
public void setHidden(boolean value)
public boolean hasCustomStyle()
public void applyStyle(Style style, StyleFlag flag)
style - The style object which will be applied.flag - Flags which indicates applied formatting properties.public Style getStyle()
Remarks
Modifying the returned style object directly takes no effect for this column or any cells in this column. You have to callapplyStyle(Style,StyleFlag) or setStyle(Style) method
to apply the change to this column.public void setStyle(Style style)
Remarks
This method only sets the given style as the default style for this column, without changing the style settings for existing cells in this column. To update style settings of existing cells to the specified style at the same time, please useapplyStyle(Style,StyleFlag)style - the style to be used as the default style for cells in this column.public boolean isCollapsed()
public void setCollapsed(boolean value)
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.