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
|
| 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
Will be deleted when we make the CellType enum transition. See bug 59791. |
HSSFComment |
getCellComment()
Returns comment associated with this cell
|
String |
getCellFormula()
Return a formula for the cell, for example,
SUM(C4:E4) |
HSSFCellStyle |
getCellStyle()
get the style for the cell.
|
CellType |
getCellType()
get the cells type (numeric, formula or string)
|
CellType |
getCellTypeEnum()
Deprecated.
|
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.
|
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 |
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 errorCode)
Deprecated.
3.15 beta 2. Use
setCellErrorValue(FormulaError) instead. |
void |
setCellErrorValue(FormulaError error)
set a error value for the cell
|
void |
setCellFormula(String formula)
Sets formula for this cell.
|
void |
setCellStyle(CellStyle style)
Set the style for the cell.
|
void |
setCellStyle(HSSFCellStyle style) |
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(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 |
setHyperlink(Hyperlink hyperlink)
Assign a hyperlink to this cell.
|
String |
toString()
Returns a string representation of the cell
This method returns a simple representation,
anything more complex should be in user code, with
knowledge of the semantics of the sheet being processed.
|
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
public HSSFSheet getSheet()
public HSSFRow getRow()
public int getRowIndex()
CellgetRowIndex in interface Cellpublic int getColumnIndex()
CellgetColumnIndex in interface Cellpublic CellAddress getAddress()
getAddress in interface CellA1 style address of this cellpublic void setCellType(CellType cellType)
setCellType in interface Cellpublic CellType getCellType()
getCellType in interface Cell@Deprecated @Removal(version="4.2") public CellType getCellTypeEnum()
getCellTypeEnum in interface Cellpublic void setCellValue(double value)
setCellValue in interface 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 void setCellValue(Date value)
setCellValue in interface 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(Calendar value)
setCellValue(value.getTime()) which will
automatically shift the times to the default timezone.setCellValue in interface 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 void setCellValue(String value)
setCellValue in interface Cellvalue - 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 Cellvalue - 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 Cellformula - the formula to set, e.g. "SUM(C4:E4)".
If the argument is null then the current formula is removed.public String getCellFormula()
CellSUM(C4:E4)getCellFormula in interface Cellpublic double getNumericCellValue()
HSSFDataFormatter for turning this
number into a string similar to that which
Excel would render this number as.getNumericCellValue in interface Cellfor 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 Cellfor formatting this date into a string similar to how excel does.public String getStringCellValue()
getStringCellValue in interface Cellpublic HSSFRichTextString getRichStringCellValue()
getRichStringCellValue in interface Cellpublic void setCellValue(boolean value)
setCellValue in interface 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 void setCellErrorValue(byte errorCode)
setCellErrorValue(FormulaError) instead.setCellErrorValue in interface 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.
For error code byte, see FormulaError.FormulaErrorpublic void setCellErrorValue(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 boolean getBooleanCellValue()
getBooleanCellValue in interface Cellpublic byte getErrorCellValue()
getErrorCellValue in interface Cellfor error codespublic void setCellStyle(CellStyle style)
Set the style for the cell. The style should be an HSSFCellStyle created/retreived from the HSSFWorkbook.
To change the style of a cell without affecting other cells that use the same style,
use CellUtil.setCellStyleProperties(org.apache.poi.ss.usermodel.Cell, java.util.Map)
setCellStyle in interface Cellstyle - reference contained in the workbookHSSFWorkbook.createCellStyle(),
HSSFWorkbook.getCellStyleAt(int)public void setCellStyle(HSSFCellStyle style)
public HSSFCellStyle getCellStyle()
getCellStyle in interface Cellworkbook.getCellStyleAt(0)HSSFWorkbook.getCellStyleAt(int)public void setAsActiveCell()
setAsActiveCell in interface Cellpublic String toString()
public void setCellComment(Comment comment)
setCellComment in interface Cellcomment - comment associated with this cellpublic HSSFComment getCellComment()
getCellComment in interface Cellpublic void removeCellComment()
removeCellComment in interface Cellpublic HSSFHyperlink getHyperlink()
getHyperlink in interface Cellnull if not foundpublic void setHyperlink(Hyperlink hyperlink)
setHyperlink in interface Cellhyperlink - hyperlink associated with this cellpublic void removeHyperlink()
removeHyperlink in interface Cellpublic CellType getCachedFormulaResultType()
getCachedFormulaResultType in interface CellCellType.NUMERIC, CellType.STRING,
CellType.BOOLEAN, CellType.ERROR) depending
on the cached value of the formula@Deprecated @Removal(version="4.2") public CellType getCachedFormulaResultTypeEnum()
getCachedFormulaResultType
Will be deleted when we make the CellType enum transition. See bug 59791.getCachedFormulaResultTypeEnum in interface CellCellType.NUMERIC, CellType.STRING,
CellType.BOOLEAN, CellType.ERROR) depending
on the cached value of the formulapublic CellRangeAddress getArrayFormulaRange()
CellgetArrayFormulaRange in interface Cellpublic boolean isPartOfArrayFormulaGroup()
isPartOfArrayFormulaGroup in interface Celltrue if this cell is part of group of cells having a common array formula.Copyright © 2010 - 2020 Adobe. All Rights Reserved