|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.poi.hssf.usermodel.HSSFCell
public final class HSSFCell
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 | |
---|---|
static int |
CELL_TYPE_BLANK
Blank Cell type (3) @see #setCellType(int) @see #getCellType() |
static int |
CELL_TYPE_BOOLEAN
Boolean Cell type (4) @see #setCellType(int) @see #getCellType() |
static int |
CELL_TYPE_ERROR
Error Cell type (5) @see #setCellType(int) @see #getCellType() |
static int |
CELL_TYPE_FORMULA
Formula Cell type (2) @see #setCellType(int) @see #getCellType() |
static int |
CELL_TYPE_NUMERIC
Numeric Cell type (0) @see #setCellType(int) @see #getCellType() |
static int |
CELL_TYPE_STRING
String Cell type (1) @see #setCellType(int) @see #getCellType() |
static short |
ENCODING_COMPRESSED_UNICODE
|
static short |
ENCODING_UNCHANGED
|
static short |
ENCODING_UTF_16
|
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
protected static HSSFComment |
findCellComment(Sheet sheet,
int row,
int column)
Cell comment finder. |
boolean |
getBooleanCellValue()
get the value of the cell as a boolean. |
protected Workbook |
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 |
java.lang.String |
getCellFormula()
|
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()
|
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. |
HSSFHyperlink |
getHyperlink()
Returns hyperlink associated with this cell |
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. |
int |
getRowIndex()
|
HSSFSheet |
getSheet()
|
java.lang.String |
getStringCellValue()
Deprecated. Use the HSSFRichTextString return |
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(HSSFComment comment)
Assign a comment to this cell. |
void |
setCellErrorValue(byte errorCode)
set a error value for the cell |
void |
setCellFormula(java.lang.String formula)
|
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(HSSFCellStyle 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(HSSFRichTextString value)
set a string value for the cell. |
void |
setCellValue(java.lang.String value)
Deprecated. Use setCellValue(HSSFRichTextString) instead. |
void |
setHyperlink(HSSFHyperlink link)
Assign a hypelrink to this cell |
java.lang.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) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int CELL_TYPE_NUMERIC
public static final int CELL_TYPE_STRING
public static final int CELL_TYPE_FORMULA
public static final int CELL_TYPE_BLANK
public static final int CELL_TYPE_BOOLEAN
public static final int CELL_TYPE_ERROR
public static final short ENCODING_UNCHANGED
public static final short ENCODING_COMPRESSED_UNICODE
public static final short ENCODING_UTF_16
Constructor Detail |
---|
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 representMethod Detail |
---|
public HSSFSheet getSheet()
protected Workbook getBoundWorkbook()
public int getRowIndex()
public void setCellNum(short num)
HSSFRow.moveCell(HSSFCell, short)
instead
num
- short the cell numberprotected void updateCellNum(short num)
num
- the new cell numberpublic short getCellNum()
getColumnIndex()
public int getColumnIndex()
public void setCellType(int cellType)
CELL_TYPE_NUMERIC
,
CELL_TYPE_STRING
,
CELL_TYPE_FORMULA
,
CELL_TYPE_BLANK
,
CELL_TYPE_BOOLEAN
,
CELL_TYPE_ERROR
public int getCellType()
CELL_TYPE_STRING
,
CELL_TYPE_NUMERIC
,
CELL_TYPE_FORMULA
,
CELL_TYPE_BOOLEAN
,
CELL_TYPE_ERROR
public void setCellValue(double value)
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)
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(java.util.Calendar value)
setCellValue(value.getTime())
which will
automatically shift the times to the default timezone.
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(java.lang.String value)
setEncoding()
first.
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(HSSFRichTextString value)
setEncoding()
first.
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)
public java.lang.String getCellFormula()
public double getNumericCellValue()
HSSFDataFormatter
for turning this
number into a string similar to that which
Excel would render this number as.
public java.util.Date getDateCellValue()
HSSFDataFormatter
for formatting
this date into a string similar to how excel does.
public java.lang.String getStringCellValue()
public HSSFRichTextString getRichStringCellValue()
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 errorCode)
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.public boolean getBooleanCellValue()
public byte getErrorCellValue()
public void setCellStyle(HSSFCellStyle style)
style
- reference contained in the workbookHSSFWorkbook.createCellStyle()
,
HSSFWorkbook.getCellStyleAt(short)
public HSSFCellStyle getCellStyle()
HSSFWorkbook.getCellStyleAt(short)
protected CellValueRecordInterface getCellValueRecord()
public void setAsActiveCell()
public java.lang.String toString()
toString
in class java.lang.Object
public void setCellComment(HSSFComment comment)
comment
- comment associated with this cellpublic HSSFComment getCellComment()
public void removeCellComment()
protected static HSSFComment findCellComment(Sheet sheet, int row, int column)
null
if not foundpublic HSSFHyperlink getHyperlink()
public void setHyperlink(HSSFHyperlink link)
link
- hypelrink associated with this cellpublic int getCachedFormulaResultType()
CELL_TYPE_NUMERIC
, CELL_TYPE_STRING
,
CELL_TYPE_BOOLEAN
, CELL_TYPE_ERROR
) depending
on the cached value of the formula
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |