ExcelColumn Class
Excel column contains column options and cell range with column cells.
public sealed class ExcelColumn : ExcelColumnRowBase
Public NotInheritable Class ExcelColumn
Inherits ExcelColumnRowBase
- Inheritance:
- System.ObjectExcelColumn
Remarks
Note that the cells are internally allocated in rows and not in columns. ExcelColumn objects are created only if they have non-standard width or style, or they are accessed directly. So, while ExcelRowCollection.Count shows number of rows occupied with data, ExcelColumnCollection.Count does not say which Column is the last one occupied with data!
If you want to read all data in a sheet, use AllocatedCells property.
If you want to find last column occupied with data, use CalculateMaxUsedColumns() method.
Properties
Width
Gets or sets the column width.
Property Value
- System.Int32
The column width.
Remarks
Value is a numerator (before a slash) of a fraction in a formula for an Open XML column width.
See Also
Methods
AutoFit()
Automatically fits column width to the minimum size required for all data in the column to be visible.
AutoFit(Double)
Automatically fits column width to the minimum size required for all data in the column to be visible.
[ComVisible(true)]
public void AutoFit(double scaling)
<ComVisible(True)>
Public Sub AutoFit(scaling As Double)
Parameters
scaling
- System.Double
Scaling factor.
Remarks
Scaling factor is used to adjust the width of the column. Resulting column width is equal to CalculatedWidth * scaling. Default scaling is 1.
AutoFit(Double, ExcelRow, ExcelRow)
Automatically fits column width by checking only the cells in the column that are specified by row range.
[ComVisible(false)]
public void AutoFit(double scaling, ExcelRow firstRow, ExcelRow lastRow)
<ComVisible(False)>
Public Sub AutoFit(scaling As Double, firstRow As ExcelRow, lastRow As ExcelRow)
Parameters
scaling
- System.Double
Scaling factor.
firstRow
- ExcelRow
First row.
lastRow
- ExcelRow
Last row.
Remarks
Scaling factor is used to adjust the width of the column. Resulting column width is equal to CalculatedWidth * scaling. Default scaling is 1.
GetWidth(LengthUnit)
Gets the width of column in arbitrary length unit.
public double GetWidth(LengthUnit lengthUnit)
Public Function GetWidth(lengthUnit As LengthUnit) As Double
Parameters
lengthUnit
- LengthUnit
The length unit in which to return column width.
Returns
- System.Double
The width of column in arbitrary length unit.
SetWidth(Double, LengthUnit)
Sets the width of column in arbitrary length unit.
public void SetWidth(double value, LengthUnit lengthUnit)
Public Sub SetWidth(value As Double, lengthUnit As LengthUnit)
Parameters
value
- System.Double
Column width value.
lengthUnit
- LengthUnit
The length unit in which value
is specified.
Inherited Properties
Cells | Gets cell range with column / row cells. (Inherited from ExcelColumnRowBase) |
Collapsed | Gets or sets whether object is collapsed in outlining. (Inherited from ExcelColumnRowBase) |
Hidden | Gets or sets whether excel object is hidden. (Inherited from ExcelColumnRowBase) |
Index | Gets the row / column zero-based index which represents its position in a worksheet. (Inherited from ExcelColumnRowBase) |
Name | Gets the name of ExcelColumnRowBase instance. (Inherited from ExcelColumnRowBase) |
OutlineLevel | Gets or sets outline level. (Inherited from ExcelColumnRowBase) |
Style | Gets or sets the cell formatting of cells in this column / row. (Inherited from ExcelColumnRowBase) |
Inherited Methods
Equals(System.Object) | Determines whether the specified System.Object is equal to this ExcelColumnRowBase instance. (Inherited from ExcelColumnRowBase) |
GetHashCode() | Returns a hash code for this ExcelColumnRowBase instance. (Inherited from ExcelColumnRowBase) |
ToString() | Returns a System.String that represents this ExcelColumnRowBase instance. (Inherited from ExcelColumnRowBase) |