Class Column
Represents a column in a worksheet.
Inherited Members
Namespace: DRIT.Spreadsheet
Assembly: DRIT.Spreadsheet.dll
Syntax
public class Column : AbstractFormattable
Remarks
A Column represents a vertical collection of cells in a worksheet.
Columns can have custom width, visibility settings, and formatting applied.
Columns are accessed through the Columns collection.
Examples
// Access and format a column
var column = worksheet.Columns[0]; // Column A
column.Width = 20.0;
column.IsHidden = false;
Fields
MaximumCharacterWidth
The maximum allowed width for a column in characters.
Declaration
public const double MaximumCharacterWidth = 255
Field Value
| Type | Description |
|---|---|
| double |
Remarks
A Column represents a vertical collection of cells in a worksheet.
Columns can have custom width, visibility settings, and formatting applied.
Columns are accessed through the Columns collection.
Properties
Address
Gets the cell address representing this column.
Declaration
public CellAddress Address { get; }
Property Value
| Type | Description |
|---|---|
| CellAddress |
Remarks
The address represents the first cell in the column (row 0).
Cells
Returns a cell-index accessor for this column.
Declaration
public ColumnCellsAccessor Cells { get; }
Property Value
| Type | Description |
|---|---|
| ColumnCellsAccessor |
Remarks
Usage: column.Cells[rowIndex]
CustomWidthCharacters
Gets the custom width set for the column in characters with five pixels padding.
Declaration
public double? CustomWidthCharacters { get; }
Property Value
| Type | Description |
|---|---|
| double? |
Remarks
In OpenXml the additional 5 pixels padding is also stored. If the width is not explicitly set, return the default width for the worksheet.
CustomWidthSet
Gets whether custom width is set for column.
Declaration
public bool CustomWidthSet { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
A Column represents a vertical collection of cells in a worksheet.
Columns can have custom width, visibility settings, and formatting applied.
Columns are accessed through the Columns collection.
Index
Gets the zero-based index of the column.
Declaration
public int Index { get; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
A Column represents a vertical collection of cells in a worksheet.
Columns can have custom width, visibility settings, and formatting applied.
Columns are accessed through the Columns collection.
IsCollapsed
Gets or sets whether the column is collapsed.
Declaration
public bool IsCollapsed { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
A Column represents a vertical collection of cells in a worksheet.
Columns can have custom width, visibility settings, and formatting applied.
Columns are accessed through the Columns collection.
IsHidden
Gets or sets whether the column is hidden.
Declaration
public bool IsHidden { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
A Column represents a vertical collection of cells in a worksheet.
Columns can have custom width, visibility settings, and formatting applied.
Columns are accessed through the Columns collection.
Label
Gets the label (letter designation) of the column, such as "A", "B", or "AA".
Declaration
public string Label { get; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
A Column represents a vertical collection of cells in a worksheet.
Columns can have custom width, visibility settings, and formatting applied.
Columns are accessed through the Columns collection.
OutlineLevel
Specifies the outline level of the row/ group.
Declaration
public int OutlineLevel { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
A Column represents a vertical collection of cells in a worksheet.
Columns can have custom width, visibility settings, and formatting applied.
Columns are accessed through the Columns collection.
WidthCharacters
Specifies the column width in characters without five pixels padding.
Declaration
public double WidthCharacters { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Remarks
If this value is not set it return the default character width of the worksheet.
WidthPixels
Specifies the width of the column in pixels with five pixels padding.
Declaration
public double WidthPixels { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Remarks
A Column represents a vertical collection of cells in a worksheet.
Columns can have custom width, visibility settings, and formatting applied.
Columns are accessed through the Columns collection.
Methods
Add(Cell)
Adds a cell to the column's internal storage.
Declaration
public void Add(Cell cell)
Parameters
| Type | Name | Description |
|---|---|---|
| Cell | cell | The cell to add to the column. |
Remarks
A Column represents a vertical collection of cells in a worksheet.
Columns can have custom width, visibility settings, and formatting applied.
Columns are accessed through the Columns collection.
Autofit()
Adjust the width of the column so that it fits its content.
Declaration
public void Autofit()
Remarks
A Column represents a vertical collection of cells in a worksheet.
Columns can have custom width, visibility settings, and formatting applied.
Columns are accessed through the Columns collection.
Autofit(int, int)
Adjust the width of the column so that it fits its content, considering only cells in the specified row range.
Declaration
public void Autofit(int fromRow, int toRow)
Parameters
| Type | Name | Description |
|---|---|---|
| int | fromRow | Zero-based index of the first row to consider. |
| int | toRow | Zero-based index of the last row to consider. |
Remarks
A Column represents a vertical collection of cells in a worksheet.
Columns can have custom width, visibility settings, and formatting applied.
Columns are accessed through the Columns collection.
Remove(Cell)
Removes a cell from the column's internal storage.
Declaration
public void Remove(Cell cell)
Parameters
| Type | Name | Description |
|---|---|---|
| Cell | cell | The cell to remove from the column. |
Remarks
A Column represents a vertical collection of cells in a worksheet.
Columns can have custom width, visibility settings, and formatting applied.
Columns are accessed through the Columns collection.
SetDefaultWidth()
Sets the column to the default width for the worksheet.
Declaration
public void SetDefaultWidth()
Remarks
A Column represents a vertical collection of cells in a worksheet.
Columns can have custom width, visibility settings, and formatting applied.
Columns are accessed through the Columns collection.
Operators
operator +(Column, int)
Adds an offset to a column to get another column.
Declaration
public static Column operator +(Column This, int offset)
Parameters
| Type | Name | Description |
|---|---|---|
| Column | This | The source column. |
| int | offset | The number of columns to offset by. |
Returns
| Type | Description |
|---|---|
| Column | The column at the offset position. |
Remarks
A Column represents a vertical collection of cells in a worksheet.
Columns can have custom width, visibility settings, and formatting applied.
Columns are accessed through the Columns collection.