GemBox.Spreadsheet presents workbook content in a hierarchical structure with an ExcelFile as a main class in the hierarchy.
The following sections describe GemBox.Spreadsheet content model classes and properties, and some behaviors and operations common to GemBox.Spreadsheet content model classes.
The following diagram shows GemBox.Spreadsheet content model hierarchy - a parent / child relationship between workbook elements.
Each class and property in the diagram links to its help page, so you can easily navigate to details of each workbook content member.
Following list contains answers to the most common questions related to GemBox.Spreadsheet content model.
Use ExcelWorksheetCollectionActiveWorksheet property.
Active worksheet is the one selected when file is opened with Microsoft Excel. By default active worksheet is the first one added with ExcelWorksheetCollectionAdd(String) method.
Use ExcelWorksheetCalculateMaxUsedColumns method.
This method will iterate over all rows and find the maximum number of used columns.
Use ExcelWorksheetGetUsedCellRange(Boolean) method.
If method parameter ignoreCellsWithoutValue is set to true, then allocated cells with ExcelCellValue set to null are ignored. This parameter is useful because cell might be allocated even if it doesn't have a value. For example, it could have just background color, number format or some other style applied via AbstractRangeStyle property.
Method ExcelWorksheetGetUsedCellRange(Boolean) will return null if there are no used cells in the worksheet.
Use ExcelRowAllocatedCells property.
Use this property if you are reading entire workbook (you don't know exact position of cells with data). When writing values, using ExcelColumnRowBaseCells property is recommended.
Collection returned from this property contains only allocated cells so it is faster as you avoid checking every single cell in a row. You still need to check if a specific cell contains any value (it can be empty).
Cell index: use CellRangeRowColumnToPosition(Int32, Int32) and CellRangePositionToRowColumn(String, Int32, Int32) static methods.
Use ExcelCellGetFormattedValue method.