Package org.apache.poi.ss.util
Class SheetBuilder
java.lang.Object
org.apache.poi.ss.util.SheetBuilder
Class
SheetBuilder provides an easy way of building workbook sheets
from 2D array of Objects. It can be used in test cases to improve code
readability or in Swing applications with tables.- Author:
- Roman Kashitsyn
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds sheet from parent workbook and 2D array with cell values.booleanReturnstrueif null array elements should be treated as empty cells.setCreateEmptyCells(boolean shouldCreateEmptyCells) Specifies if null array elements should be treated as empty cells.setSheetName(String sheetName) Specifies name of the sheet to build.
-
Constructor Details
-
SheetBuilder
-
-
Method Details
-
getCreateEmptyCells
public boolean getCreateEmptyCells()Returnstrueif null array elements should be treated as empty cells.- Returns:
trueif null objects should be treated as empty cells andfalseotherwise
-
setCreateEmptyCells
Specifies if null array elements should be treated as empty cells.- Parameters:
shouldCreateEmptyCells-trueif null array elements should be treated as empty cells- Returns:
this
-
setSheetName
Specifies name of the sheet to build. If not specified, default name (provided by workbook) will be used instead.- Parameters:
sheetName- sheet name to use- Returns:
this
-
build
Builds sheet from parent workbook and 2D array with cell values. Creates rows anyway (even if row contains only null cells), creates cells if either corresponding array value is not null or createEmptyCells property is true. The conversion is performed in the following way:- Numbers become numeric cells.
java.util.Dateorjava.util.Calendarinstances become date cells.- String with leading '=' char become formulas (leading '=' will be truncated).
- Other objects become strings via
Object.toString()method call.
- Returns:
- newly created sheet
-