Collection of excel columns (ExcelColumn).
Inheritance Hierarchy
GemBox.Spreadsheet ExcelRowColumnCellCollectionBase
GemBox.Spreadsheet ExcelRowColumnCollectionBase
GemBox.Spreadsheet ExcelRowColumnCollectionBase ExcelColumn
GemBox.Spreadsheet ExcelColumnCollection
Namespace: GemBox.Spreadsheet
Assembly: GemBox.Spreadsheet (in GemBox.Spreadsheet.dll) Version: 37.3.30.1035
Syntax
public sealed class ExcelColumnCollection : ExcelRowColumnCollectionBase<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 ExcelRow.AllocatedCells property.
If you want to find last column occupied with data, use CalculateMaxUsedColumns method.
Examples
Following code shows how to get hidden columns and shows how to get number of columns occupied with data.
foreach (ExcelColumn column in ws.Columns) { // Writes hidden columns if(column.Hidden) Console.WriteLine("Column '{0}' is hidden", ExcelColumnCollection.ColumnIndexToName(column.Index)); } // Counts used columns (columns that contain some data) Console.WriteLine("Number of used columns is: {0}", ws.CalculateMaxUsedColumns());
See Also