public class HSSFCell extends Object implements Cell
Cells should have their number (0 based) before being added to a row. Only cells that have values should be added.
Modifier and Type | Field and Description |
---|---|
static short |
ENCODING_COMPRESSED_UNICODE |
static short |
ENCODING_UNCHANGED |
static short |
ENCODING_UTF_16 |
static int |
LAST_COLUMN_NUMBER
The maximum number of columns in BIFF8
|
CELL_TYPE_BLANK, CELL_TYPE_BOOLEAN, CELL_TYPE_ERROR, CELL_TYPE_FORMULA, CELL_TYPE_NUMERIC, CELL_TYPE_STRING
Modifier | Constructor and Description |
---|---|
protected |
HSSFCell(HSSFWorkbook book,
HSSFSheet sheet,
CellValueRecordInterface cval)
Creates an HSSFCell from a CellValueRecordInterface.
|
protected |
HSSFCell(HSSFWorkbook book,
HSSFSheet sheet,
int row,
short col)
Creates new Cell - Should only be called by HSSFRow.
|
protected |
HSSFCell(HSSFWorkbook book,
HSSFSheet sheet,
int row,
short col,
int type)
Creates new Cell - Should only be called by HSSFRow.
|
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.
|
protected InternalWorkbook |
getBoundWorkbook()
Returns the Workbook that this Cell is bound to
|
int |
getCachedFormulaResultType()
Only valid for formula cells
|
HSSFComment |
getCellComment()
Returns comment associated with this cell
|
String |
getCellFormula()
Return a formula for the cell, for example,
SUM(C4:E4) |
short |
getCellNum()
Deprecated.
(Oct 2008) use
getColumnIndex() |
HSSFCellStyle |
getCellStyle()
get the style for the cell.
|
int |
getCellType()
get the cells type (numeric, formula or string)
|
protected CellValueRecordInterface |
getCellValueRecord()
Should only be used by HSSFSheet and friends.
|
int |
getColumnIndex()
Returns column index of this cell
|
Date |
getDateCellValue()
Get the value of the cell as a date.
|
byte |
getErrorCellValue()
get the value of the cell as an error code.
|
Hyperlink |
getEvalHyperlink() |
HSSFHyperlink |
getHyperlink() |
double |
getNumericCellValue()
Get the value of the cell as a number.
|
HSSFRichTextString |
getRichStringCellValue()
get the value of the cell as a string - for numeric cells we throw an exception.
|
HSSFRow |
getRow()
Returns the HSSFRow this cell belongs to
|
int |
getRowIndex()
Returns row index of a row in the sheet that contains this cell
|
HSSFSheet |
getSheet()
Returns the HSSFSheet this cell belongs to
|
String |
getStringCellValue()
get the value of the cell as a string - for numeric cells we throw an exception.
|
boolean |
isCalcOnLoad()
Old Excel spec(Used in old XLS Excel).
|
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(Comment comment)
Assign a comment to this cell.
|
void |
setCellErrorValue(byte errorCode)
set a error value for the cell
|
void |
setCellFormula(String formula)
Sets formula for this cell.
|
void |
setCellNum(short num)
Deprecated.
(Jan 2008) Doesn't update the row's idea of what cell this is, use
HSSFRow.moveCell(HSSFCell, short) instead |
void |
setCellStyle(CellStyle style)
set the style for the cell.
|
void |
setCellStyle(HSSFCellStyle style) |
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(Calendar value)
set a date value for the cell.
|
void |
setCellValue(Date value)
set a date value for the cell.
|
void |
setCellValue(double value)
set a numeric value for the cell
|
void |
setCellValue(RichTextString value)
Set a string value for the cell.
|
void |
setCellValue(String value)
set a string value for the cell.
|
void |
setEvalHyperlink(Hyperlink hyperlink) |
void |
setHyperlink(Hyperlink hyperlink)
Assign a hyperlink to this cell
|
String |
toString()
Returns a string representation of the cell
This method returns a simple representation,
anthing more complex should be in user code, with
knowledge of the semantics of the sheet being processed.
|
protected void |
updateCellNum(short num)
Updates the cell record's idea of what
column it belongs in (0 based)
|
public static final int LAST_COLUMN_NUMBER
public static final short ENCODING_UNCHANGED
public static final short ENCODING_COMPRESSED_UNICODE
public static final short ENCODING_UTF_16
protected HSSFCell(HSSFWorkbook book, HSSFSheet sheet, int row, short col)
When the cell is initially created it is set to CELL_TYPE_BLANK. Cell types can be changed/overwritten by calling setCellValue with the appropriate type as a parameter although conversions from one type to another may be prohibited.
book
- - Workbook record of the workbook containing this cellsheet
- - Sheet record of the sheet containing this cellrow
- - the row of this cellcol
- - the column for this cellHSSFRow.createCell(short)
protected HSSFCell(HSSFWorkbook book, HSSFSheet sheet, int row, short col, int type)
book
- - Workbook record of the workbook containing this cellsheet
- - Sheet record of the sheet containing this cellrow
- - the row of this cellcol
- - the column for this celltype
- - CELL_TYPE_NUMERIC, CELL_TYPE_STRING, CELL_TYPE_FORMULA, CELL_TYPE_BLANK,
CELL_TYPE_BOOLEAN, CELL_TYPE_ERROR
Type of cellHSSFRow.createCell(short,int)
protected HSSFCell(HSSFWorkbook book, HSSFSheet sheet, CellValueRecordInterface cval)
book
- - Workbook record of the workbook containing this cellsheet
- - Sheet record of the sheet containing this cellcval
- - the Cell Value Record we wish to representpublic HSSFSheet getSheet()
public HSSFRow getRow()
protected InternalWorkbook getBoundWorkbook()
public int getRowIndex()
Cell
getRowIndex
in interface Cell
public void setCellNum(short num)
HSSFRow.moveCell(HSSFCell, short)
insteadnum
- short the cell numberprotected void updateCellNum(short num)
num
- the new cell numberpublic short getCellNum()
getColumnIndex()
public int getColumnIndex()
Cell
getColumnIndex
in interface Cell
public void setCellType(int cellType)
setCellType
in interface Cell
Cell.CELL_TYPE_NUMERIC
,
Cell.CELL_TYPE_STRING
,
Cell.CELL_TYPE_FORMULA
,
Cell.CELL_TYPE_BLANK
,
Cell.CELL_TYPE_BOOLEAN
,
Cell.CELL_TYPE_ERROR
public int getCellType()
getCellType
in interface Cell
Cell.CELL_TYPE_STRING
,
Cell.CELL_TYPE_NUMERIC
,
Cell.CELL_TYPE_FORMULA
,
Cell.CELL_TYPE_BOOLEAN
,
Cell.CELL_TYPE_ERROR
public 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(Date value)
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 other types we
will change the cell to a numeric cell and set its value.public void setCellValue(Calendar value)
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(String value)
setCellValue
in interface Cell
value
- 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(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 setCellFormula(String formula)
Cell
Note, this method only sets the formula string and does not calculate the formula value.
To set the precalculated value use Cell.setCellValue(double)
or Cell.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.public String getCellFormula()
Cell
SUM(C4:E4)
getCellFormula
in interface Cell
public double getNumericCellValue()
HSSFDataFormatter
for turning this
number into a string similar to that which
Excel would render this number as.getNumericCellValue
in interface Cell
for turning this number into a string similar to that which Excel would render this number as.
public Date getDateCellValue()
HSSFDataFormatter
for formatting
this date into a string similar to how excel does.getDateCellValue
in interface Cell
for formatting this date into a string similar to how excel does.
public String getStringCellValue()
getStringCellValue
in interface Cell
public HSSFRichTextString getRichStringCellValue()
getRichStringCellValue
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 errorCode)
setCellErrorValue
in interface Cell
errorCode
- 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()
getBooleanCellValue
in interface Cell
public byte getErrorCellValue()
getErrorCellValue
in interface Cell
for error codes
public void setCellStyle(CellStyle style)
setCellStyle
in interface Cell
style
- reference contained in the workbookHSSFWorkbook.createCellStyle()
,
org.zkoss.poi.hssf.usermodel.HSSFWorkbook#getCellStyleAt(short)
public void setCellStyle(HSSFCellStyle style)
public HSSFCellStyle getCellStyle()
getCellStyle
in interface Cell
workbook.getCellStyleAt(0)
org.zkoss.poi.hssf.usermodel.HSSFWorkbook#getCellStyleAt(short)
protected CellValueRecordInterface getCellValueRecord()
public void setAsActiveCell()
setAsActiveCell
in interface Cell
public String toString()
public void setCellComment(Comment comment)
setCellComment
in interface Cell
comment
- comment associated with this cellpublic HSSFComment getCellComment()
getCellComment
in interface Cell
public void removeCellComment()
removeCellComment
in interface Cell
public HSSFHyperlink getHyperlink()
getHyperlink
in interface Cell
null
if not foundpublic void setHyperlink(Hyperlink hyperlink)
setHyperlink
in interface Cell
hyperlink
- hyperlink associated with this cellpublic int getCachedFormulaResultType()
getCachedFormulaResultType
in interface Cell
Cell.CELL_TYPE_NUMERIC
, Cell.CELL_TYPE_STRING
,
Cell.CELL_TYPE_BOOLEAN
, Cell.CELL_TYPE_ERROR
) depending
on the cached value of the formulapublic CellRangeAddress getArrayFormulaRange()
Cell
getArrayFormulaRange
in interface Cell
public boolean isPartOfArrayFormulaGroup()
isPartOfArrayFormulaGroup
in interface Cell
true
if this cell is part of group of cells having a common array formula.public void setEvalHyperlink(Hyperlink hyperlink)
public Hyperlink getEvalHyperlink()
public boolean isCalcOnLoad()
Cell
isCalcOnLoad
in interface Cell
Copyright © 2020. All rights reserved.