|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.poi.xssf.usermodel.XSSFCell
public final class XSSFCell
High level representation of a cell in a row of a spreadsheet.
Cells can be numeric, formula-based or string-based (text). The cell type specifies this. String cells cannot conatin numbers and numeric cells cannot contain strings (at least according to our model). Client apps should do the conversions themselves. Formula cells have the formula string, as well as the formula result, which can be numeric or string.
Cells should have their number (0 based) before being added to a row. Only cells that have values should be added.
| Field Summary |
|---|
| Fields inherited from interface org.apache.poi.ss.usermodel.Cell |
|---|
CELL_TYPE_BLANK, CELL_TYPE_BOOLEAN, CELL_TYPE_ERROR, CELL_TYPE_FORMULA, CELL_TYPE_NUMERIC, CELL_TYPE_STRING |
| Method Summary | |
|---|---|
org.apache.poi.ss.util.CellRangeAddress |
getArrayFormulaRange()
|
boolean |
getBooleanCellValue()
Get the value of the cell as a boolean. |
int |
getCachedFormulaResultType()
Only valid for formula cells |
org.apache.poi.ss.usermodel.Comment |
getCellComment()
Returns cell comment associated with this cell |
java.lang.String |
getCellFormula()
Return a formula for the cell, for example, SUM(C4:E4) |
org.apache.poi.ss.usermodel.CellStyle |
getCellStyle()
Return the cell's style. |
int |
getCellType()
Return the cell type. |
int |
getColumnIndex()
Returns column index of this cell |
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell |
getCTCell()
Returns the xml bean containing information about the cell's location (reference), value, data type, formatting, and formula |
java.util.Date |
getDateCellValue()
Get the value of the cell as a date. |
java.lang.String |
getErrorCellString()
Returns the error message, such as #VALUE! |
byte |
getErrorCellValue()
Get the value of the cell as an error code. |
org.apache.poi.ss.usermodel.Hyperlink |
getHyperlink()
Returns hyperlink associated with this cell |
double |
getNumericCellValue()
Get the value of the cell as a number. |
java.lang.String |
getRawValue()
Returns the raw, underlying ooxml value for the cell |
java.lang.String |
getReference()
Returns an A1 style reference to the location of this cell |
org.apache.poi.ss.usermodel.RichTextString |
getRichStringCellValue()
Get the value of the cell as a XSSFRichTextString |
org.apache.poi.ss.usermodel.Row |
getRow()
Returns the row this cell belongs to |
int |
getRowIndex()
Returns row index of a row in the sheet that contains this cell |
org.apache.poi.ss.usermodel.Sheet |
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 |
setAsActiveCell()
Sets this cell as the active cell for the worksheet. |
void |
setCellComment(org.apache.poi.ss.usermodel.Comment comment)
Assign a comment to this cell. |
void |
setCellErrorValue(byte errorCode)
Set a error value for the cell |
void |
setCellErrorValue(org.apache.poi.ss.usermodel.FormulaError error)
Set a error value for the cell |
void |
setCellFormula(java.lang.String formula)
Sets formula for this cell. |
void |
setCellStyle(org.apache.poi.ss.usermodel.CellStyle style)
Set the style for the cell. |
void |
setCellType(int 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)
Set a date value for the cell. |
void |
setCellValue(double value)
Set a numeric value for the cell |
void |
setCellValue(org.apache.poi.ss.usermodel.RichTextString str)
Set a string value for the cell. |
void |
setCellValue(java.lang.String str)
Set a string value for the cell. |
void |
setHyperlink(org.apache.poi.ss.usermodel.Hyperlink hyperlink)
Assign a hypelrink to this cell |
java.lang.String |
toString()
Returns a string representation of the cell |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public org.apache.poi.ss.usermodel.Sheet getSheet()
getSheet in interface org.apache.poi.ss.usermodel.Cellpublic org.apache.poi.ss.usermodel.Row getRow()
getRow in interface org.apache.poi.ss.usermodel.Cellpublic boolean getBooleanCellValue()
For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
getBooleanCellValue in interface org.apache.poi.ss.usermodel.Celljava.lang.IllegalStateException - if the cell type returned by getCellType()
is not CELL_TYPE_BOOLEAN, CELL_TYPE_BLANK or CELL_TYPE_FORMULApublic void setCellValue(boolean value)
setCellValue in interface org.apache.poi.ss.usermodel.Cellvalue - 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 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 org.apache.poi.ss.usermodel.Celljava.lang.IllegalStateException - if the cell type returned by getCellType() is CELL_TYPE_STRING
java.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 void setCellValue(double value)
setCellValue in interface org.apache.poi.ss.usermodel.Cellvalue - 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 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 org.apache.poi.ss.usermodel.Cellpublic org.apache.poi.ss.usermodel.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 org.apache.poi.ss.usermodel.Cellpublic void setCellValue(java.lang.String str)
setCellValue in interface org.apache.poi.ss.usermodel.Cellstr - value to set the cell to. For formulas we'll set the formula
cached string result, 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(org.apache.poi.ss.usermodel.RichTextString str)
setCellValue in interface org.apache.poi.ss.usermodel.Cellstr - value to set the cell to. For formulas we'll set the 'pre-evaluated result 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 java.lang.String getCellFormula()
SUM(C4:E4)
getCellFormula in interface org.apache.poi.ss.usermodel.Celljava.lang.IllegalStateException - if the cell type returned by getCellType() is not CELL_TYPE_FORMULApublic void setCellFormula(java.lang.String formula)
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 org.apache.poi.ss.usermodel.Cellformula - the formula to set, e.g. "SUM(C4:E4)".
If the argument is null then the current formula is removed.
org.apache.poi.ss.formula.FormulaParseException - if the formula has incorrect syntax or is otherwise invalid
java.lang.IllegalStateException - if the operation is not allowed, for example,
when the cell is a part of a multi-cell array formulapublic int getColumnIndex()
getColumnIndex in interface org.apache.poi.ss.usermodel.Cellpublic int getRowIndex()
getRowIndex in interface org.apache.poi.ss.usermodel.Cellpublic java.lang.String getReference()
public org.apache.poi.ss.usermodel.CellStyle getCellStyle()
getCellStyle in interface org.apache.poi.ss.usermodel.Cellpublic void setCellStyle(org.apache.poi.ss.usermodel.CellStyle style)
setCellStyle in interface org.apache.poi.ss.usermodel.Cellstyle - 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.public int getCellType()
getCellType in interface org.apache.poi.ss.usermodel.CellCell.CELL_TYPE_BLANK,
Cell.CELL_TYPE_NUMERIC,
Cell.CELL_TYPE_STRING,
Cell.CELL_TYPE_FORMULA,
Cell.CELL_TYPE_BOOLEAN,
Cell.CELL_TYPE_ERRORpublic int getCachedFormulaResultType()
getCachedFormulaResultType in interface org.apache.poi.ss.usermodel.CellCell.CELL_TYPE_NUMERIC, Cell.CELL_TYPE_STRING,
Cell.CELL_TYPE_BOOLEAN, Cell.CELL_TYPE_ERROR) depending
on the cached value of the formulapublic java.util.Date getDateCellValue()
For strings we throw an exception. For blank cells we return a null.
getDateCellValue in interface org.apache.poi.ss.usermodel.Celljava.lang.IllegalStateException - if the cell type returned by getCellType() is CELL_TYPE_STRING
java.lang.NumberFormatException - if the cell value isn't a parsable double.for formatting this date into a string similar to how excel does.public void setCellValue(java.util.Date value)
setCellValue in interface org.apache.poi.ss.usermodel.Cellvalue - the date 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.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 org.apache.poi.ss.usermodel.Cellvalue - 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 java.lang.String getErrorCellString()
java.lang.IllegalStateException - if the cell type returned by getCellType() isn't CELL_TYPE_ERRORFormulaErrorpublic byte getErrorCellValue()
For strings, numbers, and booleans, we throw an exception. For blank cells we return a 0.
getErrorCellValue in interface org.apache.poi.ss.usermodel.Celljava.lang.IllegalStateException - if the cell type returned by getCellType() isn't CELL_TYPE_ERRORFormulaErrorpublic void setCellErrorValue(byte errorCode)
setCellErrorValue in interface org.apache.poi.ss.usermodel.CellerrorCode - 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.FormulaErrorpublic void setCellErrorValue(org.apache.poi.ss.usermodel.FormulaError error)
error - 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.public void setAsActiveCell()
setAsActiveCell in interface org.apache.poi.ss.usermodel.Cellpublic void setCellType(int cellType)
setCellType in interface org.apache.poi.ss.usermodel.Celljava.lang.IllegalArgumentException - if the specified cell type is invalidCell.CELL_TYPE_NUMERIC,
Cell.CELL_TYPE_STRING,
Cell.CELL_TYPE_FORMULA,
Cell.CELL_TYPE_BLANK,
Cell.CELL_TYPE_BOOLEAN,
Cell.CELL_TYPE_ERRORpublic 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.Objectpublic java.lang.String getRawValue()
If the cell contains a string, then this value is an index into the shared string table, pointing to the actual string value. Otherwise, the value of the cell is expressed directly in this element. Cells containing formulas express the last calculated result of the formula in this element.
null for blank cells.public org.apache.poi.ss.usermodel.Comment getCellComment()
getCellComment in interface org.apache.poi.ss.usermodel.Cellnullpublic void setCellComment(org.apache.poi.ss.usermodel.Comment comment)
setCellComment in interface org.apache.poi.ss.usermodel.Cellcomment - the XSSFComment associated with this cellpublic void removeCellComment()
removeCellComment in interface org.apache.poi.ss.usermodel.Cellpublic org.apache.poi.ss.usermodel.Hyperlink getHyperlink()
getHyperlink in interface org.apache.poi.ss.usermodel.Cellnull if not foundpublic void setHyperlink(org.apache.poi.ss.usermodel.Hyperlink hyperlink)
setHyperlink in interface org.apache.poi.ss.usermodel.Cellhyperlink - the hypelrink to associate with this cellpublic org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell getCTCell()
public org.apache.poi.ss.util.CellRangeAddress getArrayFormulaRange()
getArrayFormulaRange in interface org.apache.poi.ss.usermodel.Cellpublic boolean isPartOfArrayFormulaGroup()
isPartOfArrayFormulaGroup in interface org.apache.poi.ss.usermodel.Cell
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||