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.
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.
Following list contains answers to the most common questions related to GemBox.Spreadsheet content model.
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.
Use ExcelWorksheet.calculateMaxUsedColumns() method.
This method will iterate over all rows and find the maximum number of used columns.
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.
Method ExcelWorksheet.getUsedCellRange(boolean) will return null if there are no used cells in the worksheet.
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).
Use ExcelCell.getFormattedValue() method.