public class CellUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
CELL_TYPE_BLANK
Blank Cell type (3)
|
static int |
CELL_TYPE_BOOLEAN
Boolean Cell type (4)
|
static int |
CELL_TYPE_ERROR
Error Cell type (5)
|
static int |
CELL_TYPE_FORMULA
Formula Cell type (2)
|
static int |
CELL_TYPE_NUMERIC
Numeric Cell type (0)
|
static int |
CELL_TYPE_STRING
String Cell type (1)
|
protected static org.slf4j.Logger |
log |
| Modifier | Constructor and Description |
|---|---|
protected |
CellUtils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
getBooleanCellValue(Cell _cell)
Get the value of the cell as a boolean.
|
static CTCellStyle |
getCellStyle(Cell _cell)
Return the cell's style.
|
static int |
getCellType(Cell _cell)
Return the cell type.
|
static Date |
getDateCellValue(Cell _cell)
Get the value of the cell as a date.
|
static long |
getNumberFormatIndex(Cell _cell)
Get the index of the number format (numFmt) record used by this cell format.
|
static String |
getNumberFormatString(Cell _cell)
Get the contents of the format string, by looking up
the StylesSource
|
static double |
getNumericCellValue(Cell _cell)
Get the value of the cell as a number.
|
static RuntimeException |
typeMismatch(int expectedTypeCode,
int actualTypeCode,
boolean isFormulaCell)
Used to help format error messages
|
protected static org.slf4j.Logger log
public static final int CELL_TYPE_NUMERIC
#setCellType(int),
#getCellType(),
Constant Field Valuespublic static final int CELL_TYPE_STRING
#setCellType(int),
#getCellType(),
Constant Field Valuespublic static final int CELL_TYPE_FORMULA
#setCellType(int),
#getCellType(),
Constant Field Valuespublic static final int CELL_TYPE_BLANK
#setCellType(int),
#getCellType(),
Constant Field Valuespublic static final int CELL_TYPE_BOOLEAN
#setCellType(int),
#getCellType(),
Constant Field Valuespublic static final int CELL_TYPE_ERROR
#setCellType(int),
#getCellType(),
Constant Field Valuespublic static double getNumericCellValue(Cell _cell)
For strings we throw an exception. For blank cells we return a 0. For formulas or error cells we return the precalculated value;
IllegalStateException - if the cell type returned by #getCellType() is CELL_TYPE_STRINGNumberFormatException - if the cell value isn't a parsable double.for turning this number into a string similar to that which Excel would render this number as.public static RuntimeException typeMismatch(int expectedTypeCode, int actualTypeCode, boolean isFormulaCell)
public static int getCellType(Cell _cell)
Cell#CELL_TYPE_BLANK,
Cell#CELL_TYPE_NUMERIC,
Cell#CELL_TYPE_STRING,
Cell#CELL_TYPE_FORMULA,
Cell#CELL_TYPE_BOOLEAN,
Cell#CELL_TYPE_ERRORpublic static CTCellStyle getCellStyle(Cell _cell)
public static long getNumberFormatIndex(Cell _cell)
public static String getNumberFormatString(Cell _cell)
public static Date getDateCellValue(Cell _cell)
For strings we throw an exception. For blank cells we return a null.
IllegalStateException - if the cell type returned by #getCellType() is CELL_TYPE_STRINGNumberFormatException - if the cell value isn't a parsable double.for formatting this date into a string similar to how excel does.public static boolean getBooleanCellValue(Cell _cell)
For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
IllegalStateException - if the cell type returned by #getCellType()
is not CELL_TYPE_BOOLEAN, CELL_TYPE_BLANK or CELL_TYPE_FORMULACopyright © 2007-2022. All Rights Reserved.