Class Column

Class Column

Namespace: Aspose.Cells
Assembly: Aspose.Cells.dll (25.2.0)

Represents a single column in a worksheet.

public class Column

Inheritance

objectColumn

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Examples

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

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

Properties

GroupLevel

Gets the group level of the column.

public byte GroupLevel { get; set; }

Property Value

byte

HasCustomStyle

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

public bool HasCustomStyle { get; }

Property Value

bool

Index

Gets the index of this column.

public int Index { get; }

Property Value

int

IsCollapsed

whether the column is collapsed

public bool IsCollapsed { get; set; }

Property Value

bool

IsHidden

Indicates whether the column is hidden.

public bool IsHidden { get; set; }

Property Value

bool

Width

Gets and sets the column width in unit of characters.

public double Width { get; set; }

Property Value

double

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.

Methods

ApplyStyle(Style, StyleFlag)

Applies formats for a whole column.

public void ApplyStyle(Style style, StyleFlag flag)

Parameters

style Style

The style object which will be applied.

flag StyleFlag

Flags which indicates applied formatting properties.

GetStyle()

Gets the style of this column.

public Style GetStyle()

Returns

Style

Remarks

Modifying the returned style object directly takes no effect for this column or any cells in this column. You have to call Aspose.Cells.Column.ApplyStyle(Aspose.Cells.Style,Aspose.Cells.StyleFlag) or Aspose.Cells.Column.SetStyle(Aspose.Cells.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)

SetStyle(Style)

Sets the style of this column.

public void SetStyle(Style style)

Parameters

style Style

the style to be used as the default style for cells in 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 Aspose.Cells.Column.ApplyStyle(Aspose.Cells.Style,Aspose.Cells.StyleFlag)