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

    Show / Hide Table of Contents

    ExcelColumnCollection Class

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

    Collection of excel columns (ExcelColumn).

    • C#
    • VB.NET
    public sealed class ExcelColumnCollection : ExcelRowColumnCollectionBase<ExcelColumn>, IEnumerable<ExcelColumn>, IEnumerable
    Public NotInheritable Class ExcelColumnCollection
        Inherits ExcelRowColumnCollectionBase(Of ExcelColumn)
        Implements IEnumerable(Of ExcelColumn), IEnumerable
    Inheritance:
    System.Object
    ExcelRowColumnCellCollectionBase
    ExcelRowColumnCollectionBase
    ExcelRowColumnCollectionBase<ExcelColumn>
    ExcelColumnCollection
    Implements
    System.Collections.Generic.IEnumerable<ExcelColumn>
    System.Collections.IEnumerable
    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

    Item[Int32]

    Gets the column with the specified index.

    • C#
    • VB.NET
    public override ExcelColumn this[int index] { get; }
    Public Overrides ReadOnly Property Item(index As Integer) As ExcelColumn
    Parameters
    index
    System.Int32

    The zero-based index of the column.

    Property Value
    ExcelColumn
    Overrides
    GemBox.Spreadsheet.ExcelRowColumnCollectionBase<GemBox.Spreadsheet.ExcelColumn>.Item[System.Int32]

    Methods

    ColumnIndexToName(Int32)

    Converts column index (0, 1, ...) to column name ("A", "B", ...).

    • C#
    • VB.NET
    public static string ColumnIndexToName(int columnIndex)
    Public Shared Function ColumnIndexToName(columnIndex As Integer) As String
    Parameters
    columnIndex
    System.Int32

    Column index.

    Returns
    System.String

    Column name for the specified index.

    ColumnNameToIndex(String)

    Converts column name ("A", "B", ...) to column index (0, 1, ...).

    • C#
    • VB.NET
    public static int ColumnNameToIndex(string name)
    Public Shared Function ColumnNameToIndex(name As String) As Integer
    Parameters
    name
    System.String

    Column name.

    Returns
    System.Int32

    Column index for the specified name.

    InsertCopy(Int32, ExcelColumn)

    Inserts copied column at the specified index.

    • C#
    • VB.NET
    public void InsertCopy(int columnIndex, ExcelColumn sourceColumn)
    Public Sub InsertCopy(columnIndex As Integer, sourceColumn As ExcelColumn)
    Parameters
    columnIndex
    System.Int32

    The zero-based index of the column.

    sourceColumn
    ExcelColumn

    Source column to copy.

    InsertCopy(Int32, Int32, ExcelColumn)

    Inserts specified number of copied columns at the specified index.

    • C#
    • VB.NET
    public void InsertCopy(int columnIndex, int columnCount, ExcelColumn sourceColumn)
    Public Sub InsertCopy(columnIndex As Integer, columnCount As Integer, sourceColumn As ExcelColumn)
    Parameters
    columnIndex
    System.Int32

    The zero-based index of the column.

    columnCount
    System.Int32

    Number of columns to insert.

    sourceColumn
    ExcelColumn

    Source column to copy.

    InsertEmpty(Int32)

    Inserts empty column at the specified index.

    • C#
    • VB.NET
    public void InsertEmpty(int columnIndex)
    Public Sub InsertEmpty(columnIndex As Integer)
    Parameters
    columnIndex
    System.Int32

    The zero-based index of the column.

    InsertEmpty(Int32, Int32)

    Inserts specified number of empty columns at the specified index.

    • C#
    • VB.NET
    public void InsertEmpty(int columnIndex, int columnCount)
    Public Sub InsertEmpty(columnIndex As Integer, columnCount As Integer)
    Parameters
    columnIndex
    System.Int32

    The zero-based index of the column.

    columnCount
    System.Int32

    Number of columns to insert.

    Remove(Int32)

    Removes the column with the specified index.

    • C#
    • VB.NET
    public void Remove(int columnIndex)
    Public Sub Remove(columnIndex As Integer)
    Parameters
    columnIndex
    System.Int32

    The zero-based index of the column.

    Remove(Int32, Int32)

    Removes specified number of columns starting at the specified index.

    • C#
    • VB.NET
    public void Remove(int columnIndex, int columnCount)
    Public Sub Remove(columnIndex As Integer, columnCount As Integer)
    Parameters
    columnIndex
    System.Int32

    The zero-based index of the column.

    columnCount
    System.Int32

    Number of columns to remove.

    Implements

    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable

    Examples

    Referencing ExcelCell and CellRange in C# and VB.NET

    See Also

    ExcelColumn
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.