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)protected static org.slf4j.Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.static DategetDateCellValue(Cell _cell) Get the value of the cell as a date.static 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
-
-
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:
-
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
-
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
-
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
-