Package org.xlsx4j.model
Class CellUtils
java.lang.Object
org.xlsx4j.model.CellUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intBlank Cell type (3)static final intBoolean Cell type (4)static final intError Cell type (5)static final intFormula Cell type (2)static final intNumeric Cell type (0)static final intString Cell type (1)private static final Stringprotected static org.slf4j.Loggerprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static intgetBaseCellType(Cell _cell, boolean blankCells) Detect cell type based on the "t" attribute of the CTCell beanstatic booleangetBooleanCellValue(Cell _cell) Get the value of the cell as a boolean.static CTCellStylegetCellStyle(Cell _cell) Return the cell's style.static intgetCellType(Cell _cell) Return the cell type.private static StringgetCellTypeName(int cellTypeCode) Used to help format error messagesstatic DategetDateCellValue(Cell _cell) Get the value of the cell as a date.private static StringgetFormat(int index) get the format string that matches the given format indexstatic longgetNumberFormatIndex(Cell _cell) Get the index of the number format (numFmt) record used by this cell format.static StringgetNumberFormatString(Cell _cell) Get the contents of the format string, by looking up the StylesSourcestatic doublegetNumericCellValue(Cell _cell) Get the value of the cell as a number.static RuntimeExceptiontypeMismatch(int expectedTypeCode, int actualTypeCode, boolean isFormulaCell) Used to help format error messages
-
Field Details
-
log
protected static org.slf4j.Logger log -
CELL_TYPE_NUMERIC
public static final int CELL_TYPE_NUMERICNumeric Cell type (0)- See Also:
-
#setCellType(int)#getCellType()- Constant Field Values
-
CELL_TYPE_STRING
public static final int CELL_TYPE_STRINGString Cell type (1)- See Also:
-
#setCellType(int)#getCellType()- Constant Field Values
-
CELL_TYPE_FORMULA
public static final int CELL_TYPE_FORMULAFormula Cell type (2)- See Also:
-
#setCellType(int)#getCellType()- Constant Field Values
-
CELL_TYPE_BLANK
public static final int CELL_TYPE_BLANKBlank Cell type (3)- See Also:
-
#setCellType(int)#getCellType()- Constant Field Values
-
CELL_TYPE_BOOLEAN
public static final int CELL_TYPE_BOOLEANBoolean Cell type (4)- See Also:
-
#setCellType(int)#getCellType()- Constant Field Values
-
CELL_TYPE_ERROR
public static final int CELL_TYPE_ERRORError Cell type (5)- See Also:
-
#setCellType(int)#getCellType()- Constant Field Values
-
FALSE_AS_STRING
- See Also:
-
TRUE_AS_STRING
- See Also:
-
-
Constructor Details
-
CellUtils
protected CellUtils()
-
-
Method Details
-
getNumericCellValue
Get the value of the cell as a number.For strings we throw an exception. For blank cells we return a 0. For formulas or error cells we return the precalculated value;
- Returns:
- the value of the cell as a number
- Throws:
IllegalStateException- if the cell type returned by#getCellType()is CELL_TYPE_STRINGNumberFormatException- if the cell value isn't a parsabledouble.- See Also:
-
getCellTypeName
Used to help format error messages -
typeMismatch
public static RuntimeException typeMismatch(int expectedTypeCode, int actualTypeCode, boolean isFormulaCell) Used to help format error messages -
getCellType
Return the cell type.- Returns:
- the cell type
- See Also:
-
Cell#CELL_TYPE_BLANKCell#CELL_TYPE_NUMERICCell#CELL_TYPE_STRINGCell#CELL_TYPE_FORMULACell#CELL_TYPE_BOOLEANCell#CELL_TYPE_ERROR
-
getBaseCellType
Detect cell type based on the "t" attribute of the CTCell bean -
getCellStyle
Return the cell's style.- Returns:
- the cell's style.
-
getNumberFormatIndex
Get the index of the number format (numFmt) record used by this cell format.- Returns:
- the index of the number format
-
getNumberFormatString
Get the contents of the format string, by looking up the StylesSource- Returns:
- the number format string
-
getFormat
get the format string that matches the given format index- Parameters:
index- of a format- Returns:
- string represented at index of format or null if there is not a format at that index
-
getDateCellValue
Get the value of the cell as a date.For strings we throw an exception. For blank cells we return a null.
- Returns:
- the value of the cell as a date
- Throws:
IllegalStateException- if the cell type returned by#getCellType()is CELL_TYPE_STRINGNumberFormatException- if the cell value isn't a parsabledouble.- See Also:
-
getBooleanCellValue
Get the value of the cell as a boolean.For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
- Returns:
- the value of the cell as a boolean
- Throws:
IllegalStateException- if the cell type returned by#getCellType()is not CELL_TYPE_BOOLEAN, CELL_TYPE_BLANK or CELL_TYPE_FORMULA
-