public class HSSFCell extends Object
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 |
---|---|
private Workbook |
book |
static int |
CELL_TYPE_BLANK
Blank Cell type (3)
|
static int |
CELL_TYPE_BOOLEAN
Boolean Cell type (4)
|
static int |
CELL_TYPE_ERROR
Error Cell type (5)
|
static int |
CELL_TYPE_FORMULA
Formula Cell type (2)
|
static int |
CELL_TYPE_NUMERIC
Numeric Cell type (0)
|
static int |
CELL_TYPE_STRING
String Cell type (1)
|
private int |
cellType |
private HSSFComment |
comment |
private short |
encoding |
static short |
ENCODING_COMPRESSED_UNICODE |
static short |
ENCODING_UNCHANGED |
static short |
ENCODING_UTF_16 |
private CellValueRecordInterface |
record |
private Sheet |
sheet |
private HSSFRichTextString |
stringValue |
Modifier | Constructor and Description |
---|---|
private |
HSSFCell()
private constructor to prevent blank construction
|
protected |
HSSFCell(Workbook book,
Sheet sheet,
int row,
CellValueRecordInterface cval)
Creates an HSSFCell from a CellValueRecordInterface.
|
protected |
HSSFCell(Workbook book,
Sheet sheet,
int row,
short col)
Creates new Cell - Should only be called by HSSFRow.
|
protected |
HSSFCell(Workbook book,
Sheet sheet,
int row,
short col,
int type)
Creates new Cell - Should only be called by HSSFRow.
|
Modifier and Type | Method and Description |
---|---|
private void |
checkBounds(int cellNum) |
private int |
determineType(CellValueRecordInterface cval)
used internally -- given a cell value record, figure out its type
|
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
|
HSSFComment |
getCellComment()
Returns comment associated with this cell
|
String |
getCellFormula() |
short |
getCellNum()
get the cell's number within the row
|
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.
|
Date |
getDateCellValue()
get the value of the cell as a date.
|
short |
getEncoding()
Deprecated.
As of 3-Jan-06 POI now automatically handles Unicode without forcing the encoding.
|
byte |
getErrorCellValue()
get the value of the cell as an error code.
|
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.
|
String |
getStringCellValue()
Deprecated.
Use the HSSFRichTextString return
|
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 value)
set a error value for the cell
|
void |
setCellFormula(String formula) |
void |
setCellNum(short num)
set the cell's number within the row (0 based)
|
void |
setCellStyle(HSSFCellStyle style)
set the style for the cell.
|
void |
setCellType(int cellType)
set the cells type (numeric, formula or string)
|
private void |
setCellType(int cellType,
boolean setValue,
int row,
short col,
short styleIndex)
sets the cell type.
|
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(HSSFRichTextString value)
set a string value for the cell.
|
void |
setCellValue(String value)
Deprecated.
Use setCellValue(HSSFRichTextString) instead.
|
void |
setEncoding(short encoding)
Deprecated.
As of 3-Jan-06 POI now automatically handles Unicode without forcing the encoding.
|
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.
|
public static final int CELL_TYPE_NUMERIC
setCellType(int)
,
getCellType()
,
Constant Field Valuespublic static final int CELL_TYPE_STRING
setCellType(int)
,
getCellType()
,
Constant Field Valuespublic static final int CELL_TYPE_FORMULA
setCellType(int)
,
getCellType()
,
Constant Field Valuespublic static final int CELL_TYPE_BLANK
setCellType(int)
,
getCellType()
,
Constant Field Valuespublic static final int CELL_TYPE_BOOLEAN
setCellType(int)
,
getCellType()
,
Constant Field Valuespublic static final int CELL_TYPE_ERROR
setCellType(int)
,
getCellType()
,
Constant Field Valuespublic static final short ENCODING_UNCHANGED
public static final short ENCODING_COMPRESSED_UNICODE
public static final short ENCODING_UTF_16
private int cellType
private HSSFRichTextString stringValue
private short encoding
private Workbook book
private Sheet sheet
private CellValueRecordInterface record
private HSSFComment comment
protected HSSFCell(Workbook book, Sheet 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(Workbook book, Sheet 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(Workbook book, Sheet sheet, int row, 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 representprivate HSSFCell()
private int determineType(CellValueRecordInterface cval)
protected Workbook getBoundWorkbook()
public void setCellNum(short num)
num
- short the cell numberpublic short getCellNum()
public void setCellType(int cellType)
private void setCellType(int cellType, boolean setValue, int row, short col, short styleIndex)
The @see #setCellValue method will call this method with false in setValue since it will overwrite the cell value later
public int getCellType()
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(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(Calendar 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 othertypes we
will change the cell to a numeric cell and set its value.public void setCellValue(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(String formula)
public String getCellFormula()
public double getNumericCellValue()
public Date getDateCellValue()
public 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 value)
value
- the error value to set this cell to. For formulas we'll set the
precalculated value ??? IS THIS RIGHT??? , 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)
public short getEncoding()
ENCODING_UNCHANGED
,
ENCODING_COMPRESSED_UNICODE
,
ENCODING_UTF_16
public void setEncoding(short encoding)
encoding
- either ENCODING_COMPRESSED_UNICODE (0) or ENCODING_UTF_16 (1)ENCODING_UNCHANGED
,
ENCODING_COMPRESSED_UNICODE
,
ENCODING_UTF_16
protected CellValueRecordInterface getCellValueRecord()
private void checkBounds(int cellNum)
RuntimeException
- if the bounds are exceeded.public void setAsActiveCell()
public String toString()
public void setCellComment(HSSFComment comment)
comment
- comment associated with this cellpublic HSSFComment getCellComment()
protected static HSSFComment findCellComment(Sheet sheet, int row, int column)
null
if not foundCopyright © 2016 Open Microscopy Environment