Constructor and Description |
---|
SXSSFCell(SXSSFRow row,
CellType cellType) |
Modifier and Type | Method and Description |
---|---|
CellAddress |
getAddress()
Gets the address of this cell
|
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
|
CellType |
getCachedFormulaResultTypeEnum()
Deprecated.
use
getCachedFormulaResultType instead |
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.
|
CellType |
getCellTypeEnum()
Deprecated.
use
getCellType instead |
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() |
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
|
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.
|
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 |
setCellFormula(java.lang.String formula)
Sets formula for this cell.
|
void |
setCellStyle(CellStyle style)
Set the style for the cell.
|
void |
setCellType(CellType cellType)
Set the cells type (numeric, formula or string)
|
void |
setCellValue(boolean value)
Set a boolean value for the cell
|
void |
setCellValue(java.util.Calendar value)
Set a date value for the cell.
|
void |
setCellValue(java.util.Date value)
Converts the supplied date to its equivalent Excel numeric value and sets
that into the cell.
|
void |
setCellValue(double value)
Set a numeric value for the cell
|
void |
setCellValue(RichTextString value)
Set a rich string value for the cell.
|
void |
setCellValue(java.lang.String value)
Set a string value for the cell.
|
void |
setHyperlink(Hyperlink link)
Assign a hyperlink to this cell.
|
java.lang.String |
toString()
Returns a string representation of the cell
|
public int getColumnIndex()
getColumnIndex
in interface Cell
public int getRowIndex()
getRowIndex
in interface Cell
public CellAddress getAddress()
getAddress
in interface Cell
A1
style address of this cellpublic SXSSFSheet getSheet()
public Row getRow()
public void setCellType(CellType cellType)
setCellType
in interface Cell
java.lang.IllegalArgumentException
- if the specified cell type is invalidpublic CellType getCellType()
getCellType
in interface Cell
@Deprecated @Removal(version="4.2") public CellType getCellTypeEnum()
getCellType
insteadgetCellTypeEnum
in interface Cell
public CellType getCachedFormulaResultType()
getCachedFormulaResultType
in interface Cell
CellType.NUMERIC
, CellType.STRING
,
CellType.BOOLEAN
, CellType.ERROR
) depending
on the cached value of the formula@Deprecated @Removal(version="4.2") public CellType getCachedFormulaResultTypeEnum()
getCachedFormulaResultType
insteadgetCachedFormulaResultTypeEnum
in interface Cell
CellType.NUMERIC
, CellType.STRING
,
CellType.BOOLEAN
, CellType.ERROR
) depending
on the cached value of the formulapublic void setCellValue(double value)
setCellValue
in interface Cell
value
- the numeric value to set this cell to. For formulas we'll set the
precalculated value, for numerics we'll set its value. For other types we
will change the cell to a numeric cell and set its value.public void setCellValue(java.util.Date value)
Note - There is actually no 'DATE' cell type in Excel. In many
cases (when entering date values), Excel automatically adjusts the
cell style to some date format, creating the illusion that the cell
data type is now something besides CellType.NUMERIC
. POI
does not attempt to replicate this behaviour. To make a numeric cell
display as a date, use setCellStyle(CellStyle)
etc.
setCellValue
in interface Cell
value
- the numeric value to set this cell to. For formulas we'll set the
precalculated value, for numerics we'll set its value. For other types we
will change the cell to a numerics cell and set its value.public void setCellValue(java.util.Calendar value)
This will set the cell value based on the Calendar's timezone. As Excel
does not support timezones this means that both 20:00+03:00 and
20:00-03:00 will be reported as the same value (20:00) even that there
are 6 hours difference between the two times. This difference can be
preserved by using setCellValue(value.getTime())
which will
automatically shift the times to the default timezone.
setCellValue
in interface Cell
value
- the date value to set this cell to. For formulas we'll set the
precalculated value, for numerics we'll set its value. For othertypes we
will change the cell to a numeric cell and set its value.public void setCellValue(RichTextString value)
setCellValue
in interface Cell
value
- value to set the cell to. For formulas: we'll set the formula
string, for String cells: we'll set its value. For other types we will
change the cell to a string cell and set its value.
If value is null then we will change the cell to a Blank cell.public void setCellValue(java.lang.String value)
setCellValue
in interface Cell
value
- value to set the cell to. For formulas we'll set the formula
string, for String cells we'll set its value. For other types we will
change the cell to a string cell and set its value.
If value is null then we will change the cell to a Blank cell.public void setCellFormula(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 setCellValue(double)
or setCellValue(String)
setCellFormula
in interface Cell
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 invalidpublic java.lang.String getCellFormula()
SUM(C4:E4)
getCellFormula
in interface Cell
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;
getNumericCellValue
in interface Cell
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.
getDateCellValue
in interface Cell
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.
getRichStringCellValue
in interface Cell
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.
getStringCellValue
in interface Cell
public void setCellValue(boolean value)
setCellValue
in interface Cell
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)
setCellErrorValue
in interface Cell
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.
getBooleanCellValue
in interface Cell
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.
getErrorCellValue
in interface Cell
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)
setCellStyle
in interface Cell
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()
getCellStyle
in interface Cell
workbook.getCellStyleAt(0)
Workbook.getCellStyleAt(int)
public void setAsActiveCell()
setAsActiveCell
in interface Cell
public void setCellComment(Comment comment)
setCellComment
in interface Cell
comment
- comment associated with this cellpublic Comment getCellComment()
getCellComment
in interface Cell
null
if not foundpublic void removeCellComment()
removeCellComment
in interface Cell
public Hyperlink getHyperlink()
getHyperlink
in interface Cell
null
if not foundpublic void setHyperlink(Hyperlink link)
setHyperlink
in interface Cell
link
- hyperlink associated with this cellpublic void removeHyperlink()
removeHyperlink
in interface Cell
@NotImplemented public CellRangeAddress getArrayFormulaRange()
getArrayFormulaRange
in interface Cell
@NotImplemented public boolean isPartOfArrayFormulaGroup()
isPartOfArrayFormulaGroup
in interface Cell
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 2018 The Apache Software Foundation or its licensors, as applicable.