Package io.keikai.axyra.sheets
Interface CellValue
- All Known Implementing Classes:
CellValue.Array,CellValue.Blank,CellValue.Bool,CellValue.Error,CellValue.Number,CellValue.Text
public sealed interface CellValue
permits CellValue.Number, CellValue.Text, CellValue.Bool, CellValue.Error, CellValue.Blank, CellValue.Array
One cell's value: a number, text, boolean, error or blank, or a matrix
passed to and from a user-defined function. Immutable.
Values are produced when reading a Range or
Sheet.value(int, int) and consumed when writing. A value is a
snapshot: it does not follow later edits to the cell, and changing a cell
means writing a new value. Switch on the record type to read it:
CellValue v = sheet.cell(0, 0).value();
if (v instanceof CellValue.Number n) {
double d = n.value();
} else if (v instanceof CellValue.Error e) {
String shown = e.display(); // e.g. "#DIV/0!"
}
Dates are numbers (Excel date serials); see Cell.dateValue().
A formula error (e.g. #DIV/0!) is data, carried by
CellValue.Error — it is never thrown as an exception.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordA rectangular, row-major matrix of scalar values (rows[r][c]).static final recordThe empty cell value; use the sharedBLANK.static final recordA boolean cell value.static final recordAn error cell value, identified by its ExcelERROR.TYPEcode (seeerror(int)for the codes).static final recordA numeric cell value.static final recordA text cell value. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CellValue.BlankThe value of an empty cell.static final CellValue.BoolThe booleanFALSE.static final CellValue.BoolThe booleanTRUE. -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic CellValueA row-major matrix value (seeCellValue.Array) — the shape of a range argument to a typed user-defined function, or of an array result returned from one.static CellValueblank()ReturnsBLANK, the value of an empty cell.static CellValuebool(boolean value) static CellValueerror(int code) An error value from its ExcelERROR.TYPEcode: 1#NULL!, 2#DIV/0!, 3#VALUE!, 4#REF!, 5#NAME?, 6#NUM!, 7#N/A, 8#GETTING_DATA, 9#SPILL!, 14#CALC!.static StringerrorString(int code) Maps an ExcelERROR.TYPEcode to its display string.static CellValuenumber(double value) A numeric value.static CellValueA text value, stored as typed: a numeric-looking string stays text.
-
Field Details
-
BLANK
The value of an empty cell. Writing it clears the cell's value and formula. -
TRUE
The booleanTRUE. -
FALSE
The booleanFALSE.
-
-
Method Details
-
number
A numeric value. Excel stores integers, decimals and dates alike as 64-bit floating point numbers. -
text
A text value, stored as typed: a numeric-looking string stays text. -
bool
-
error
An error value from its ExcelERROR.TYPEcode: 1#NULL!, 2#DIV/0!, 3#VALUE!, 4#REF!, 5#NAME?, 6#NUM!, 7#N/A, 8#GETTING_DATA, 9#SPILL!, 14#CALC!. Any other code is written as#VALUE!. -
blank
ReturnsBLANK, the value of an empty cell. -
array
A row-major matrix value (seeCellValue.Array) — the shape of a range argument to a typed user-defined function, or of an array result returned from one. Writing it to a cell throwsIllegalArgumentException.- Parameters:
rows- the rows, each of the same length; stored as given, not copied
-
errorString
Maps an ExcelERROR.TYPEcode to its display string. Unknown codes give#VALUE!, as in the engine.
-