Click or drag to resize

Content Model

GemBox.Spreadsheet for Java 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 for Java Content Model

The following diagram shows GemBox.Spreadsheet for Java content model hierarchy - a parent / child relationship between workbook elements.

Each class and method in the diagram links to its help page, so you can easily navigate to details of each workbook content member.

Navigate to ExcelDrawing.getPosition() methodNavigate to abstract ExcelDrawing classNavigate to ExcelChart classNavigate to ExcelWorksheet.getCharts() methodNavigate to ExcelDrawing.getHyperlink() methodNavigate to ExcelCell.getHyperlink() methodNavigate to ExcelComment classNavigate to ExcelCell.getComment() methodNavigate to SpreadsheetHyperlink classNavigate to ExcelPicture classNavigate to SheetHeaderFooter classNavigate to ExcelRow.getAllocatedCells() methodNavigate to ExcelColumnRowBase.getCells() methodNavigate to ExcelColumnRowBase.getCells() methodNavigate to ExcelRow classNavigate to ExcelColumn classNavigate to ExcelWorksheet.getHyperlinks() methodNavigate to ExcelWorksheet.getPictures() methodNavigate to ExcelWorksheet.getHeadersFooters() methodNavigate to ExcelWorksheet.getColumns() methodNavigate to ExcelWorksheet.getRows() methodNavigate to ExcelWorksheet.getCells() methodNavigate to ExcelFile.getWorksheets() methodNavigate to ExcelCell classNavigate to ExcelWorksheet classNavigate to ExcelFile classGemBox.Spreadsheet Content Model

Common operations on GemBox.Spreadsheet for Java Content Model

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

How to get/set active worksheet?

Use ExcelWorksheetCollection.setActiveWorksheet(ExcelWorksheet).

Active worksheet is the one selected when file is opened with Microsoft Excel. By default active worksheet is the first one added with ExcelWorksheetCollection.add(String) method.

How to get max. used columns in a worksheet?

Use ExcelWorksheet.calculateMaxUsedColumns() 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 ExcelWorksheet.getUsedCellRange(boolean) method.

If method parameter ignoreCellsWithoutValue is set to true, then allocated cells with ExcelCell.getValue() 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 AbstractRange.setStyle(CellStyle) method.

Caution note Caution

Method ExcelWorksheet.getUsedCellRange(boolean) will return null if there are no used cells in the worksheet.

How to iterate over cells in a row?

Use ExcelRow.getAllocatedCells() method.

Use this method if you are reading entire workbook (you don't know exact position of cells with data). When writing values, using ExcelColumnRowBase.getCells() property is recommended.

Collection returned from this method 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 ExcelCell.getFormattedValue() method.

This method uses number format specified on the AbstractRange.getStyle() to format the ExcelCell.getValue().