Column

Column class

Represents a single column in a worksheet.

public class Column

Properties

Name Description
GroupLevel { get; } Gets the group level of the column.
Index { get; } Gets the index of this column.
IsCollapsed { get; set; } whether the column is collapsed
IsHidden { get; set; } Indicates whether the column is hidden.
Style { get; } Gets the style of this column.
Width { get; set; } Gets and sets the column width in unit of characters.

Methods

Name Description
ApplyStyle(Style, StyleFlag) Applies formats for a whole column.

Examples


[C#]

//Instantiating a Workbook object
Workbook workbook = new Workbook();

//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
Style style = workbook.CreateStyle();

//Setting the background color to Blue
style.BackgroundColor = Color.Blue;

//Setting the foreground color to Red
style.ForegroundColor= Color.Red;

//setting Background Pattern
style.Pattern = BackgroundType.DiagonalStripe;

//New Style Flag
StyleFlag styleFlag = new StyleFlag();

//Set All Styles
styleFlag.All = true;

//Get first Column
Column column = worksheet.Cells.Columns[0];

//Apply Style to first Column
column.ApplyStyle(style, styleFlag);

//Saving the Excel file
workbook.Save("book1.xls");

[VB.NET]

'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()

'Obtaining the reference of the first worksheet
Dim worksheet As Worksheet = workbook.Worksheets(0)

Dim style As Style = workbook.CreateStyle()

'Setting the background color to Blue
style.BackgroundColor = Color.Blue

'Setting the foreground color to Red
style.ForegroundColor = Color.Red

'setting Background Pattern
style.Pattern = BackgroundType.DiagonalStripe

'New Style Flag
Dim styleFlag As New StyleFlag()

'Set All Styles
styleFlag.All = True

'Get first Column
Dim column As Column = worksheet.Cells.Columns(0)

'Apply Style to first Column
column.ApplyStyle(style, styleFlag)

'Saving the Excel file
workbook.Save("book1.xls")

See Also