Class SXSSFCell
- All Implemented Interfaces:
Cell
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionOnly valid for array formula cellsbooleanGet the value of the cell as a boolean.Only valid for formula cellsReturns comment associated with this cellReturn a formula for the cell, for example,SUM(C4:E4)Return the cell's style.Return the cell type.intReturns column index of this cellGet the value of the cell as a date.byteGet the value of the cell as an error code.Get the value of the cell as a LocalDateTime.doubleGet the value of the cell as a number.Get the value of the cell as a XSSFRichTextStringgetRow()Returns the Row this cell belongs tointReturns row index of a row in the sheet that contains this cellgetSheet()Returns the sheet this cell belongs toprotected SpreadsheetVersionGet the spreadsheet version for the given implementation.Get the value of the cell as a stringbooleanvoidRemoves the comment for this cell, if there is one.protected voidImplementation-specific removal of the formula.voidRemoves the hyperlink for this cell, if there is one.voidSets this cell as the active cell for the worksheetvoidsetCellComment(Comment comment) Assign a comment to this cellvoidsetCellErrorValue(byte value) Set an error value for the cellvoidsetCellFormulaImpl(String formula) Sets formula for this cell.voidsetCellStyle(CellStyle style) Set the style for the cell.protected voidsetCellTypeImpl(CellType cellType) Implementation-specific logicvoidsetCellValue(boolean value) Set a boolean value for the cellvoidsetCellValueImpl(double value) Implementation-specific way to set a numeric value.protected voidsetCellValueImpl(String value) Implementation-specific way to set a string value.protected voidsetCellValueImpl(LocalDateTime value) Implementation-specific way to set a date value.protected voidsetCellValueImpl(Calendar value) Implementation-specific way to set a calendar value.protected voidsetCellValueImpl(Date value) Implementation-specific way to set a date value.protected voidsetCellValueImpl(RichTextString value) Implementation-specific way to set a RichTextString value.voidsetHyperlink(Hyperlink link) Assign a hyperlink to this cell.toString()Returns a string representation of the cellMethods inherited from class org.apache.poi.ss.usermodel.CellBase
getAddress, getValueType, removeFormula, setBlank, setCellFormula, setCellType, setCellValue, setCellValue, setCellValue, setCellValue, setCellValue, setCellValue, tryToDeleteArrayFormulaMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.poi.ss.usermodel.Cell
setCellValue
-
Constructor Details
-
Method Details
-
getSpreadsheetVersion
Get the spreadsheet version for the given implementation.- Specified by:
getSpreadsheetVersionin classCellBase- Returns:
- the spreadsheet version
-
getColumnIndex
public int getColumnIndex()Returns column index of this cell- Returns:
- zero-based column index of a column in a sheet.
-
getRowIndex
public int getRowIndex()Returns row index of a row in the sheet that contains this cell- Returns:
- zero-based row index of a row in the sheet that contains this cell
-
getSheet
Returns the sheet this cell belongs to- Returns:
- the sheet this cell belongs to
-
getRow
Returns the Row this cell belongs to- Returns:
- the Row that owns this cell
-
setCellTypeImpl
Description copied from class:CellBaseImplementation-specific logic- Specified by:
setCellTypeImplin classCellBase- Parameters:
cellType- new cell type. Guaranteed non-null, not _NONE.
-
getCellType
Return the cell type.- Returns:
- the cell type
-
getCachedFormulaResultType
Only valid for formula cells- Returns:
- one of (
CellType.NUMERIC,CellType.STRING,CellType.BOOLEAN,CellType.ERROR) depending on the cached value of the formula - Throws:
IllegalStateException- if cell is not a formula cell
-
setCellValueImpl
public void setCellValueImpl(double value) Implementation-specific way to set a numeric value.valueis 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 returnCellType.NUMERIC.- Specified by:
setCellValueImplin classCellBase- Parameters:
value- the new value to set
-
setCellValueImpl
Implementation-specific way to set a date value.valueis guaranteed to be non-null. The implementation is expected to adjust the cell type accordingly, so that after this call getCellType() or getCachedFormulaResultType() would returnCellType.NUMERIC.- Specified by:
setCellValueImplin classCellBase- Parameters:
value- the new date to set
-
setCellValueImpl
Implementation-specific way to set a date value.valueis guaranteed to be non-null. The implementation is expected to adjust the cell type accordingly, so that after this call getCellType() or getCachedFormulaResultType() would returnCellType.NUMERIC.- Specified by:
setCellValueImplin classCellBase- Parameters:
value- the new date to set
-
setCellValueImpl
Implementation-specific way to set a calendar value.valueis guaranteed to be non-null. The implementation is expected to adjust the cell type accordingly, so that after this call getCellType() or getCachedFormulaResultType() would returnCellType.NUMERIC.- Specified by:
setCellValueImplin classCellBase- Parameters:
value- the new calendar value to set
-
setCellValueImpl
Implementation-specific way to set a RichTextString value. The value is guaranteed to be non-null, having non-null value, and to satisfy the length limitation imposed by the spreadsheet version. The implementation is expected to adjust cell type accordingly, so that after this call getCellType() or getCachedFormulaResultType() (whichever appropriate) would returnCellType.STRING.- Specified by:
setCellValueImplin classCellBase- Parameters:
value- the new value to set.
-
setCellValueImpl
Implementation-specific way to set a string value. The value is guaranteed to be non-null and to satisfy the length limitation imposed by the spreadsheet version. The implementation is expected to adjust cell type accordingly, so that after this call getCellType() or getCachedFormulaResultType() (whichever appropriate) would returnCellType.STRING.- Specified by:
setCellValueImplin classCellBase- Parameters:
value- the new value to set.
-
setCellFormulaImpl
Sets formula for this cell.Note, this method only sets the formula string and does not calculate the formula value. To set the precalculated value use
CellBase.setCellValue(double)orCellBase.setCellValue(String)- Specified by:
setCellFormulaImplin classCellBase- Parameters:
formula- the formula to set, e.g."SUM(C4:E4)". If the argument isnullthen the current formula is removed.- Throws:
FormulaParseException- if the formula has incorrect syntax or is otherwise invalid
-
removeFormulaImpl
protected void removeFormulaImpl()Description copied from class:CellBaseImplementation-specific removal of the formula. The cell is guaranteed to have a regular formula set. Shall preserve the "cached" value.- Specified by:
removeFormulaImplin classCellBase
-
getCellFormula
Return a formula for the cell, for example,SUM(C4:E4)- Returns:
- a formula for the cell
- Throws:
IllegalStateException- if the cell type returned bygetCellType()is not CellType.FORMULA
-
getNumericCellValue
public double 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 bygetCellType()is CellType.STRINGNumberFormatException- if the cell value isn't a parsabledouble.- See Also:
-
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 bygetCellType()is CellType.STRINGNumberFormatException- if the cell value isn't a parsabledouble.- See Also:
-
getLocalDateTimeCellValue
Get the value of the cell as a LocalDateTime.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 bygetCellType()is CellType.STRINGNumberFormatException- if the cell value isn't a parsabledouble.- See Also:
-
getRichStringCellValue
Get the value of the cell as a XSSFRichTextStringFor 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.
- Returns:
- the value of the cell as a XSSFRichTextString
-
getStringCellValue
Get the value of the cell as a stringFor 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.
- Returns:
- the value of the cell as a string
-
setCellValue
public void setCellValue(boolean value) Set a boolean value for the cell- Parameters:
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.
-
setCellErrorValue
public void setCellErrorValue(byte value) Set an error value for the cell- Parameters:
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.- See Also:
-
getBooleanCellValue
public boolean 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 bygetCellType()is not CellType.BOOLEAN, CellType.BLANK or CellType.FORMULA
-
getErrorCellValue
public byte getErrorCellValue()Get the value of the cell as an error code.For strings, numbers, and booleans, we throw an exception. For blank cells we return a 0.
- Returns:
- the value of the cell as an error code
- Throws:
IllegalStateException- if the cell type returned bygetCellType()isn't CellType.ERROR- See Also:
-
setCellStyle
Set the style for the cell. The style should be an CellStyle created/retrieved from the Workbook.
To change the style of a cell without affecting other cells that use the same style, use
CellUtil.setCellStylePropertiesEnum(Cell, Map)- Parameters:
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.- See Also:
-
getCellStyle
Return the cell's style. Since POI v5.2.3, this returns the column style if the cell has no style of its own. If no column default style is set, the row default style is checked. This method has always fallen back to return the default style if there is no other style to return.- Returns:
- the cell's style. Never null. Default cell style has zero index and can be obtained as
workbook.getCellStyleAt(0) - See Also:
-
setAsActiveCell
public void setAsActiveCell()Sets this cell as the active cell for the worksheet -
setCellComment
Assign a comment to this cell- Parameters:
comment- comment associated with this cell
-
getCellComment
Returns comment associated with this cell- Returns:
- comment associated with this cell or
nullif not found
-
removeCellComment
public void removeCellComment()Removes the comment for this cell, if there is one. -
getHyperlink
- Returns:
- hyperlink associated with this cell or
nullif not found
-
setHyperlink
Assign a hyperlink to this cell. If the supplied hyperlink is null, the hyperlink for this cell will be removed.- Parameters:
link- hyperlink associated with this cell
-
removeHyperlink
public void removeHyperlink()Removes the hyperlink for this cell, if there is one. -
getArrayFormulaRange
Only valid for array formula cells- Returns:
- range of the array formula group that the cell belongs to.
-
isPartOfArrayFormulaGroup
- Returns:
trueif this cell is part of group of cells having a common array formula.
-
toString
Returns a string representation of the cellFormula cells return the formula string, rather than the formula result. Dates are displayed in dd-MMM-yyyy format Errors are displayed as #ERR<errIdx>
-