ExcelColumnCollection Class
Collection of excel columns (ExcelColumn).
public sealed class ExcelColumnCollection : ExcelRowColumnCollectionBase<ExcelColumn>, IEnumerable<ExcelColumn>, IEnumerable
Public NotInheritable Class ExcelColumnCollection
Inherits ExcelRowColumnCollectionBase(Of ExcelColumn)
Implements IEnumerable(Of ExcelColumn), IEnumerable
- Inheritance:
- System.ObjectExcelColumnCollection
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.
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
Overrides
Methods
ColumnIndexToName(Int32)
Converts column index (0, 1, ...) to column name ("A", "B", ...).
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, ...).
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.
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.
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.
Parameters
columnIndex
- System.Int32
The zero-based index of the column.
InsertEmpty(Int32, Int32)
Inserts specified number of empty columns at the specified index.
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.
Parameters
columnIndex
- System.Int32
The zero-based index of the column.
Remove(Int32, Int32)
Removes specified number of columns starting at the specified index.
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.