Constructor and Description |
---|
SXSSFCell(SXSSFRow row,
CellType cellType) |
Modifier and Type | Method and Description |
---|---|
CellRangeAddress |
getArrayFormulaRange()
Only valid for array formula cells
|
boolean |
getBooleanCellValue()
Get the value of the cell as a boolean.
|
CellType |
getCachedFormulaResultType()
Only valid for formula cells
|
Comment |
getCellComment()
Returns comment associated with this cell
|
java.lang.String |
getCellFormula()
Return a formula for the cell, for example,
SUM(C4:E4) |
CellStyle |
getCellStyle()
Return the cell's style.
|
CellType |
getCellType()
Return the cell type.
|
int |
getColumnIndex()
Returns column index of this cell
|
java.util.Date |
getDateCellValue()
Get the value of the cell as a date.
|
byte |
getErrorCellValue()
Get the value of the cell as an error code.
|
Hyperlink |
getHyperlink() |
java.time.LocalDateTime |
getLocalDateTimeCellValue()
Get the value of the cell as a LocalDateTime.
|
double |
getNumericCellValue()
Get the value of the cell as a number.
|
RichTextString |
getRichStringCellValue()
Get the value of the cell as a XSSFRichTextString
|
Row |
getRow()
Returns the Row this cell belongs to
|
int |
getRowIndex()
Returns row index of a row in the sheet that contains this cell
|
SXSSFSheet |
getSheet()
Returns the sheet this cell belongs to
|
protected SpreadsheetVersion |
getSpreadsheetVersion()
Get the spreadsheet version for the given implementation.
|
java.lang.String |
getStringCellValue()
Get the value of the cell as a string
|
boolean |
isPartOfArrayFormulaGroup() |
void |
removeCellComment()
Removes the comment for this cell, if there is one.
|
protected void |
removeFormulaImpl()
Implementation-specific removal of the formula.
|
void |
removeHyperlink()
Removes the hyperlink for this cell, if there is one.
|
void |
setAsActiveCell()
Sets this cell as the active cell for the worksheet
|
void |
setCellComment(Comment comment)
Assign a comment to this cell
|
void |
setCellErrorValue(byte value)
Set a error value for the cell
|
void |
setCellFormulaImpl(java.lang.String formula)
Sets formula for this cell.
|
void |
setCellStyle(CellStyle style)
Set the style for the cell.
|
protected void |
setCellTypeImpl(CellType cellType)
Implementation-specific logic
|
void |
setCellValue(boolean value)
Set a boolean value for the cell
|
protected void |
setCellValueImpl(java.util.Calendar value)
Implementation-specific way to set a calendar value.
|
protected void |
setCellValueImpl(java.util.Date value)
Implementation-specific way to set a date value.
|
void |
setCellValueImpl(double value)
Implementation-specific way to set a numeric value.
|
protected void |
setCellValueImpl(java.time.LocalDateTime value)
Implementation-specific way to set a date value.
|
protected void |
setCellValueImpl(RichTextString value)
Implementation-specific way to set a RichTextString value.
|
protected void |
setCellValueImpl(java.lang.String value)
Implementation-specific way to set a string value.
|
void |
setHyperlink(Hyperlink link)
Assign a hyperlink to this cell.
|
java.lang.String |
toString()
Returns a string representation of the cell
|
getAddress, getValueType, removeFormula, setBlank, setCellFormula, setCellType, setCellValue, setCellValue, setCellValue, setCellValue, setCellValue, setCellValue, tryToDeleteArrayFormula
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
setCellValue
protected SpreadsheetVersion getSpreadsheetVersion()
getSpreadsheetVersion
in class CellBase
public int getColumnIndex()
public int getRowIndex()
public SXSSFSheet getSheet()
public Row getRow()
protected void setCellTypeImpl(CellType cellType)
CellBase
setCellTypeImpl
in class CellBase
cellType
- new cell type. Guaranteed non-null, not _NONE.public CellType getCellType()
public CellType getCachedFormulaResultType()
CellType.NUMERIC
, CellType.STRING
,
CellType.BOOLEAN
, CellType.ERROR
) depending
on the cached value of the formulapublic void setCellValueImpl(double value)
value
is guaranteed to be a valid (non-NaN) double.
The implementation is expected to adjust the cell type accordingly, so that after this call
getCellType() or getCachedFormulaResultType() would return CellType.NUMERIC
.setCellValueImpl
in class CellBase
value
- the new value to setprotected void setCellValueImpl(java.util.Date value)
value
is guaranteed to be non-null.
The implementation is expected to adjust the cell type accordingly, so that after this call
getCellType() or getCachedFormulaResultType() would return CellType.NUMERIC
.setCellValueImpl
in class CellBase
value
- the new date to setprotected void setCellValueImpl(java.time.LocalDateTime value)
value
is guaranteed to be non-null.
The implementation is expected to adjust the cell type accordingly, so that after this call
getCellType() or getCachedFormulaResultType() would return CellType.NUMERIC
.setCellValueImpl
in class CellBase
value
- the new date to setprotected void setCellValueImpl(java.util.Calendar value)
value
is guaranteed to be non-null.
The implementation is expected to adjust the cell type accordingly, so that after this call
getCellType() or getCachedFormulaResultType() would return CellType.NUMERIC
.setCellValueImpl
in class CellBase
value
- the new calendar value to setprotected void setCellValueImpl(RichTextString value)
CellType.STRING
.setCellValueImpl
in class CellBase
value
- the new value to set.protected void setCellValueImpl(java.lang.String value)
CellType.STRING
.setCellValueImpl
in class CellBase
value
- the new value to set.public void setCellFormulaImpl(java.lang.String formula) throws FormulaParseException
Note, this method only sets the formula string and does not calculate the formula value.
To set the precalculated value use CellBase.setCellValue(double)
or CellBase.setCellValue(String)
setCellFormulaImpl
in class CellBase
formula
- the formula to set, e.g. "SUM(C4:E4)"
.
If the argument is null
then the current formula is removed.FormulaParseException
- if the formula has incorrect syntax or is otherwise invalidprotected void removeFormulaImpl()
CellBase
removeFormulaImpl
in class CellBase
public java.lang.String getCellFormula()
SUM(C4:E4)
java.lang.IllegalStateException
- if the cell type returned by getCellType()
is not CellType.FORMULApublic double getNumericCellValue()
For strings we throw an exception. For blank cells we return a 0. For formulas or error cells we return the precalculated value;
java.lang.IllegalStateException
- if the cell type returned by getCellType()
is CellType.STRINGjava.lang.NumberFormatException
- 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 java.util.Date getDateCellValue()
For strings we throw an exception. For blank cells we return a null.
java.lang.IllegalStateException
- if the cell type returned by getCellType()
is CellType.STRINGjava.lang.NumberFormatException
- if the cell value isn't a parsable double
.for formatting this date into a string similar to how excel does.
public java.time.LocalDateTime getLocalDateTimeCellValue()
For strings we throw an exception. For blank cells we return a null.
java.lang.IllegalStateException
- if the cell type returned by getCellType()
is CellType.STRINGjava.lang.NumberFormatException
- if the cell value isn't a parsable double
.for formatting this date into a string similar to how excel does.
public RichTextString getRichStringCellValue()
For numeric cells we throw an exception. For blank cells we return an empty string. For formula cells we return the pre-calculated value if a string, otherwise an exception.
public java.lang.String getStringCellValue()
For numeric cells we throw an exception. For blank cells we return an empty string. For formulaCells that are not string Formulas, we throw an exception.
public void setCellValue(boolean value)
value
- the boolean value to set this cell to. For formulas we'll set the
precalculated value, for booleans we'll set its value. For other types we
will change the cell to a boolean cell and set its value.public void setCellErrorValue(byte value)
value
- the error value to set this cell to. For formulas we'll set the
precalculated value , for errors we'll set
its value. For other types we will change the cell to an error
cell and set its value.FormulaError
public boolean getBooleanCellValue()
For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
java.lang.IllegalStateException
- if the cell type returned by getCellType()
is not CellType.BOOLEAN, CellType.BLANK or CellType.FORMULApublic byte getErrorCellValue()
For strings, numbers, and booleans, we throw an exception. For blank cells we return a 0.
java.lang.IllegalStateException
- if the cell type returned by getCellType()
isn't CellType.ERRORfor error codes
public void setCellStyle(CellStyle style)
Set the style for the cell. The style should be an CellStyle created/retreived from the Workbook.
To change the style of a cell without affecting other cells that use the same style,
use CellUtil.setCellStyleProperties(Cell, Map)
style
- reference contained in the workbook.
If the value is null then the style information is removed causing the cell to used the default workbook style.Workbook.createCellStyle()
public CellStyle getCellStyle()
workbook.getCellStyleAt(0)
Workbook.getCellStyleAt(int)
public void setAsActiveCell()
public void setCellComment(Comment comment)
comment
- comment associated with this cellpublic Comment getCellComment()
null
if not foundpublic void removeCellComment()
public Hyperlink getHyperlink()
null
if not foundpublic void setHyperlink(Hyperlink link)
link
- hyperlink associated with this cellpublic void removeHyperlink()
@NotImplemented public CellRangeAddress getArrayFormulaRange()
@NotImplemented public boolean isPartOfArrayFormulaGroup()
true
if this cell is part of group of cells having a common array formula.public java.lang.String toString()
Formula cells return the formula string, rather than the formula result. Dates are displayed in dd-MMM-yyyy format Errors are displayed as #ERR<errIdx>
toString
in class java.lang.Object
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.