GemBox.Spreadsheet
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    ExcelColumn Class

    Namespace:
    GemBox.Spreadsheet
    Assembly:
    GemBox.Spreadsheet.dll

    Excel column contains column options and cell range with column cells.

    • C#
    • VB.NET
    public sealed class ExcelColumn : ExcelColumnRowBase
    Public NotInheritable Class ExcelColumn
        Inherits ExcelColumnRowBase
    Inheritance:
    System.Object
    ExcelColumnRowBase
    ExcelColumn
    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.

    • C#
    • VB.NET
    public int Width { get; set; }
    Public Property Width As Integer
    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
    DefaultColumnWidth

    Methods

    AutoFit()

    Automatically fits column width to the minimum size required for all data in the column to be visible.

    • C#
    • VB.NET
    [ComVisible(false)]
    public void AutoFit()
    <ComVisible(False)>
    Public Sub AutoFit

    AutoFit(Double)

    Automatically fits column width to the minimum size required for all data in the column to be visible.

    • C#
    • VB.NET
    [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.

    • C#
    • VB.NET
    [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.

    • C#
    • VB.NET
    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.

    • C#
    • VB.NET
    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)

    Examples

    Referencing ExcelCell and CellRange in C# and VB.NET

    See Also

    ExcelRow
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.