Column

Inheritance: java.lang.Object

public class Column

Represents a single column in a worksheet.

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");

Methods

MethodDescription
applyStyle(Style style, StyleFlag flag)Applies formats for a whole column.
equals(Object arg0)
getClass()
getGroupLevel()Gets the group level of the column.
getIndex()Gets the index of this column.
getStyle()Gets the style of this column.
getWidth()Gets the column width in unit of characters.
hasCustomStyle()Indicates whether this column has custom style settings(different from the default one inherited from workbook).
hashCode()
isCollapsed()whether the column is collapsed
isHidden()Indicates whether the column is hidden.
notify()
notifyAll()
setCollapsed(boolean value)whether the column is collapsed
setGroupLevel(byte value)Gets the group level of the column.
setHidden(boolean value)Indicates whether the column is hidden.
setStyle(Style style)Sets the style of this column.
setWidth(double value)Sets the column width in unit of characters.
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

applyStyle(Style style, StyleFlag flag)

public void applyStyle(Style style, StyleFlag flag)

Applies formats for a whole column.

Parameters:

ParameterTypeDescription
styleStyleThe style object which will be applied.
flagStyleFlagFlags which indicates applied formatting properties.

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getGroupLevel()

public byte getGroupLevel()

Gets the group level of the column.

Returns: byte

getIndex()

public int getIndex()

Gets the index of this column.

Returns: int

getStyle()

public Style getStyle()

Gets the style of this column.

Remarks

Modifying the returned style object directly takes no effect for this column or any cells in this column. You have to call applyStyle(Style,StyleFlag) or setStyle(Style) method to apply the change to this column.

Column’s style is the style which will be inherited by cells in this column(those cells that have no custom style settings, such as existing cells that have not been set style explicitly, or those that have not been instantiated)

Returns: Style

getWidth()

public double getWidth()

Gets the column width in unit of characters.

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.

Returns: double

hasCustomStyle()

public boolean hasCustomStyle()

Indicates whether this column has custom style settings(different from the default one inherited from workbook).

Returns: boolean

hashCode()

public native int hashCode()

Returns: int

isCollapsed()

public boolean isCollapsed()

whether the column is collapsed

Returns: boolean

isHidden()

public boolean isHidden()

Indicates whether the column is hidden.

Returns: boolean

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

setCollapsed(boolean value)

public void setCollapsed(boolean value)

whether the column is collapsed

Parameters:

ParameterTypeDescription
valueboolean

setGroupLevel(byte value)

public void setGroupLevel(byte value)

Gets the group level of the column.

Parameters:

ParameterTypeDescription
valuebyte

setHidden(boolean value)

public void setHidden(boolean value)

Indicates whether the column is hidden.

Parameters:

ParameterTypeDescription
valueboolean

setStyle(Style style)

public void setStyle(Style style)

Sets the style of this column.

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 use applyStyle(Style,StyleFlag)

Parameters:

ParameterTypeDescription
styleStylethe style to be used as the default style for cells in this column.

setWidth(double value)

public void setWidth(double value)

Sets the column width in unit of characters.

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.

Parameters:

ParameterTypeDescription
valuedouble

toString()

public String toString()

Returns: java.lang.String

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int