Click or drag to resize
Content Model

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.

GemBox.Spreadsheet Content Model

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.

Navigate to ExcelDrawing.Position propertyNavigate to abstract ExcelDrawing classNavigate to ExcelChart classNavigate to ExcelWorksheet.Charts propertyNavigate to ExcelDrawing.Hyperlink propertyNavigate to ExcelCell.Hyperlink propertyNavigate to ExcelComment classNavigate to ExcelCell.Comment propertyNavigate to SpreadsheetHyperlink classNavigate to ExcelPicture classNavigate to SheetHeaderFooter classNavigate to ExcelRow.AllocatedCells propertyNavigate to ExcelColumnRowBase.Cells propertyNavigate to ExcelColumnRowBase.Cells propertyNavigate to ExcelRow classNavigate to ExcelColumn classNavigate to ExcelWorksheet.Hyperlinks propertyNavigate to ExcelWorksheet.Pictures propertyNavigate to ExcelWorksheet.HeadersFooters propertyNavigate to ExcelWorksheet.Columns propertyNavigate to ExcelWorksheet.Rows propertyNavigate to ExcelWorksheet.Cells propertyNavigate to ExcelFile.Worksheets propertyNavigate to ExcelCell classNavigate to ExcelWorksheet classNavigate to ExcelFile classGemBox.Spreadsheet Content Model

Common operations on GemBox.Spreadsheet Content Model

Following list contains answers to the most common questions related to GemBox.Spreadsheet content model.

How to get/set active worksheet?

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.

How to get max. used columns in a worksheet?

Use ExcelWorksheetCalculateMaxUsedColumns method.

This method will iterate over all rows and find the maximum number of used columns.

How to get used cell range in a worksheet?

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.

Caution note Caution

Method ExcelWorksheetGetUsedCellRange(Boolean) will return null if there are no used cells in the worksheet.

How to iterate over cells in a row?

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).

How to convert cell/row/column index to name and back?
How to get formatted cell value?

Use ExcelCellGetFormattedValue method.

This method uses NumberFormat specified on the AbstractRangeStyle to format the ExcelCellValue.