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 final HSSFWorkbook | |
| private CellType | |
| private HSSFComment | |
| private CellValueRecordInterface | |
| private final HSSFSheet | |
| private HSSFRichTextString | |
| public static final short | |
| public static final short | |
| public static final short | |
| private static final String | |
| private static final String | |
| public static final int | LAST_COLUMN_NUMBER
The maximum number of columns in BIFF8 |
| Access | Constructor and Description |
|---|---|
| protected | HSSFCell(HSSFWorkbook
- Workbook record of the workbook containing this cell book, HSSFSheet - Sheet record of the sheet containing this cell sheet, int - the row of this cell row, short - the column for this cell col)Creates new Cell - Should only be called by HSSFRow. |
| protected | HSSFCell(HSSFWorkbook
- Workbook record of the workbook containing this cell book, HSSFSheet - Sheet record of the sheet containing this cell sheet, int - the row of this cell row, short - the column for this cell col, CellType - Type of cell type)Creates new Cell - Should only be called by HSSFRow. |
| protected | HSSFCell(HSSFWorkbook
- Workbook record of the workbook containing this cell book, HSSFSheet - Sheet record of the sheet containing this cell sheet, CellValueRecordInterface - the Cell Value Record we wish to represent cval)Creates an HSSFCell from a CellValueRecordInterface. |
| Modifier and Type | Method and Description |
|---|---|
| private short | Returns: the index of a ExtendedFormatRecord record that will be referenced by the cellthe user style to apply style)Applying a user-defined style (UDS) is special. |
| private static void | |
| private static void | |
| private boolean | |
| private String | |
| private static CellType | determineType(CellValueRecordInterface cval)
used internally -- given a cell value record, figure out its type |
| public CellRangeAddress | getArrayFormulaRange()
Implements org. Only valid for array formula cells |
| public boolean | getBooleanCellValue()
Implements org. get the value of the cell as a boolean. |
| protected InternalWorkbook | |
| public CellType | Returns: one of (CellType#NUMERIC, CellType#STRING,
CellType#BOOLEAN, CellType#ERROR) depending
on the cached value of the formulaImplements org. Only valid for formula cells |
| public HSSFComment | Returns: comment associated with this cellImplements org. Returns comment associated with this cell |
| public String | getCellFormula()
Implements org. Return a formula for the cell, for example, |
| public HSSFCellStyle | |
| public CellType | getCellType()
Implements org. get the cells type (numeric, formula or string) |
| protected CellValueRecordInterface | Returns: CellValueRecordInterface representing the cell via the low level api.Should only be used by HSSFSheet and friends. |
| public int | getColumnIndex()
Implements org. Returns column index of this cell |
| public Date | getDateCellValue()
Implements org. Get the value of the cell as a date. |
| public byte | getErrorCellValue()
Implements org. get the value of the cell as an error code. |
| public HSSFHyperlink | Returns: hyperlink associated with this cell ornull if not foundImplements org.
|
| public LocalDateTime | getLocalDateTimeCellValue()
Implements org. Get the value of the cell as a LocalDateTime. |
| public double | getNumericCellValue()
Implements org. Get the value of the cell as a number. |
| public HSSFRichTextString | getRichStringCellValue()
Implements org. get the value of the cell as a string - for numeric cells we throw an exception. |
| public HSSFRow | Returns: the HSSFRow that owns this cellImplements org. Returns the HSSFRow this cell belongs to |
| public int | Returns: the (zero based) index of the row containing this cellImplements org. Returns row index of a row in the sheet that contains this cell |
| public HSSFSheet | Returns: the HSSFSheet that owns this cellImplements org. Returns the HSSFSheet this cell belongs to |
| protected SpreadsheetVersion | getSpreadsheetVersion()
Implements abstract org. Get the spreadsheet version for the given implementation. |
| public String | getStringCellValue()
Implements org. get the value of the cell as a string - for numeric cells we throw an exception. |
| public boolean | |
| private void | |
| private CellValue | |
| public void | removeCellComment()
Implements org. Removes the comment for this cell, if there is one. |
| protected void | removeFormulaImpl()
Implements abstract org. Implementation-specific removal of the formula. |
| public void | removeHyperlink()
Implements org. Removes the hyperlink for this cell, if there is one. |
| private void | |
| public void | setAsActiveCell()
Implements org. Sets this cell as the active cell for the worksheet |
| pack-priv void | |
| public void | setCellComment(Comment
comment associated with this cell comment)Implements org. Assign a comment to this cell. |
| public void | setCellErrorValue(byte
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 errorCode)FormulaError.Implements org.
Deprecated
3.15 beta 2. Use
setCellErrorValue(FormulaError) instead.
set an error value for the cell |
| public void | setCellErrorValue(FormulaError
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. error)set an error value for the cell |
| protected void | setCellFormulaImpl(String
The text of the formula to set. formula)Implements abstract org. Implementation-specific setting the formula. |
| public void | setCellStyle(CellStyle
reference contained in the workbook style)Implements org. Set the style for the cell. |
| public void | |
| private void | setCellType(CellType cellType, boolean setValue, int row, short col, short styleIndex)
sets the cell type. |
| protected void | setCellTypeImpl(CellType
new cell type. Guaranteed non-null, not _NONE. cellType)Implements abstract org. Implementation-specific logic |
| public void | setCellValue(boolean
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. value)Implements org. set a boolean value for the cell |
| protected void | setCellValueImpl(double
the new value to set value)Implements abstract org. Implementation-specific way to set a numeric value. |
| protected void | setCellValueImpl(Date
the new date to set value)Implements abstract org. Implementation-specific way to set a date value. |
| protected void | setCellValueImpl(LocalDateTime
the new date to set value)Implements abstract org. Implementation-specific way to set a date value. |
| protected void | setCellValueImpl(Calendar
the new calendar value to set value)Implements abstract org. Implementation-specific way to set a calendar value. |
| protected void | setCellValueImpl(String
the new value to set. value)Implements abstract org. Implementation-specific way to set a string value. |
| protected void | setCellValueImpl(RichTextString
the new value to set. value)Implements abstract org. Implementation-specific way to set a RichTextString value. |
| public void | setHyperlink(Hyperlink
hyperlink associated with this cell hyperlink)Implements org. Assign a hyperlink to this cell. |
| public String | toString()
Overrides java. 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. |
| private static RuntimeException | |
| protected void | updateCellNum(short
the new cell number num)Updates the cell record's idea of what column it belongs in (0 based) |
| _book | back to summary |
|---|---|
| private final HSSFWorkbook _book | |
| _cellType | back to summary |
|---|---|
| private CellType _cellType | |
| _comment | back to summary |
|---|---|
| private HSSFComment _comment | |
| _record | back to summary |
|---|---|
| private CellValueRecordInterface _record | |
| _sheet | back to summary |
|---|---|
| private final HSSFSheet _sheet | |
| _stringValue | back to summary |
|---|---|
| private HSSFRichTextString _stringValue | |
| ENCODING_COMPRESSED_UNICODE | back to summary |
|---|---|
| public static final short ENCODING_COMPRESSED_UNICODE | |
| ENCODING_UNCHANGED | back to summary |
|---|---|
| public static final short ENCODING_UNCHANGED | |
| ENCODING_UTF_16 | back to summary |
|---|---|
| public static final short ENCODING_UTF_16 | |
| FILE_FORMAT_NAME | back to summary |
|---|---|
| private static final String FILE_FORMAT_NAME | |
| LAST_COLUMN_NAME | back to summary |
|---|---|
| private static final String LAST_COLUMN_NAME | |
| LAST_COLUMN_NUMBER | back to summary |
|---|---|
| public static final int LAST_COLUMN_NUMBER The maximum number of columns in BIFF8 | |
| HSSFCell | back to summary |
|---|---|
| protected HSSFCell(HSSFWorkbook book, HSSFSheet sheet, int row, short col) Creates new Cell - Should only be called by HSSFRow. This creates a cell from scratch.
When the cell is initially created it is set to
| |
| HSSFCell | back to summary |
|---|---|
| protected HSSFCell(HSSFWorkbook book, HSSFSheet sheet, int row, short col, CellType type) Creates new Cell - Should only be called by HSSFRow. This creates a cell from scratch.
| |
| HSSFCell | back to summary |
|---|---|
| protected HSSFCell(HSSFWorkbook book, HSSFSheet sheet, CellValueRecordInterface cval) Creates an HSSFCell from a CellValueRecordInterface. HSSFSheet uses this when reading in cells from an existing sheet.
| |
| applyUserCellStyle | back to summary |
|---|---|
| private short applyUserCellStyle(HSSFCellStyle style) Applying a user-defined style (UDS) is special. Excel does not directly reference user-defined styles, but instead create a 'proxy' ExtendedFormatRecord referencing the UDS as parent. The proceudre to apply a UDS is as follows: 1. search for a ExtendedFormatRecord with parentIndex == style.getIndex() and xfType == ExtendedFormatRecord.XF_CELL. 2. if not found then create a new ExtendedFormatRecord and copy all attributes from the user-defined style and set the parentIndex to be style.getIndex() 3. return the index of the ExtendedFormatRecord, this will be assigned to the parent cell record
| |
| checkBounds | back to summary |
|---|---|
private static void checkBounds(int cellIndex)
| |
| checkFormulaCachedValueType | back to summary |
|---|---|
| private static void checkFormulaCachedValueType(CellType expectedTypeCode, FormulaRecord fr) | |
| convertCellValueToBoolean | back to summary |
|---|---|
| private boolean convertCellValueToBoolean() Chooses a new boolean value for the cell when its type is changing. Usually the caller is calling setCellType() with the intention of calling setCellValue(boolean) straight afterwards. This method only exists to give the cell a somewhat reasonable value until the setCellValue() call (if at all). TODO - perhaps a method like setCellTypeAndValue(int, Object) should be introduced to avoid this
| |
| convertCellValueToString | back to summary |
|---|---|
| private String convertCellValueToString() | |
| determineType | back to summary |
|---|---|
| private static CellType determineType(CellValueRecordInterface cval) used internally -- given a cell value record, figure out its type | |
| getArrayFormulaRange | back to summary |
|---|---|
| public CellRangeAddress getArrayFormulaRange() Implements org. Doc from org. Only valid for array formula cells
| |
| getBooleanCellValue | back to summary |
|---|---|
| public boolean getBooleanCellValue() Implements org. get the value of the cell as a boolean. For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
| |
| getBoundWorkbook | back to summary |
|---|---|
| protected InternalWorkbook getBoundWorkbook() Returns the Workbook that this Cell is bound to | |
| getCachedFormulaResultType | back to summary |
|---|---|
| public CellType getCachedFormulaResultType() Implements org. Only valid for formula cells
| |
| getCellComment | back to summary |
|---|---|
| public HSSFComment getCellComment() Implements org. Returns comment associated with this cell
| |
| getCellFormula | back to summary |
|---|---|
| public String getCellFormula() Implements org. Doc from org. Return a formula for the cell, for example, | |
| getCellStyle | back to summary |
|---|---|
| public HSSFCellStyle getCellStyle() Implements org. get the style for the cell. This is a reference to a cell style contained in the workbook object.
| |
| getCellType | back to summary |
|---|---|
| public CellType getCellType() Implements org. get the cells type (numeric, formula or string)
| |
| getCellValueRecord | back to summary |
|---|---|
| protected CellValueRecordInterface getCellValueRecord() Should only be used by HSSFSheet and friends. Returns the low level CellValueRecordInterface record
| |
| getColumnIndex | back to summary |
|---|---|
| public int getColumnIndex() Implements org. Doc from org. Returns column index of this cell
| |
| getDateCellValue | back to summary |
|---|---|
| public Date getDateCellValue() Implements org. Get the value of the cell as a date.
For strings we throw an exception.
For blank cells we return a null.
See
| |
| getErrorCellValue | back to summary |
|---|---|
| public byte getErrorCellValue() Implements org. get the value of the cell as an error code. For strings, numbers, and booleans, we throw an exception. For blank cells we return a 0.
| |
| getHyperlink | back to summary |
|---|---|
| public HSSFHyperlink getHyperlink() Implements org.
| |
| getLocalDateTimeCellValue | back to summary |
|---|---|
| public LocalDateTime getLocalDateTimeCellValue() Implements org. Get the value of the cell as a LocalDateTime.
For strings we throw an exception.
For blank cells we return a null.
See
| |
| getNumericCellValue | back to summary |
|---|---|
| public double getNumericCellValue() Implements org. Get the value of the cell as a number.
For strings we throw an exception.
For blank cells we return a 0.
See
| |
| getRichStringCellValue | back to summary |
|---|---|
| public HSSFRichTextString getRichStringCellValue() Implements org. get the value of the cell as a string - 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
| |
| getRow | back to summary |
|---|---|
| public HSSFRow getRow() Implements org. Returns the HSSFRow this cell belongs to | |
| getRowIndex | back to summary |
|---|---|
| public int getRowIndex() Implements org. Doc from org. Returns row index of a row in the sheet that contains this cell
| |
| getSheet | back to summary |
|---|---|
| public HSSFSheet getSheet() Implements org. Returns the HSSFSheet this cell belongs to | |
| getSpreadsheetVersion | back to summary |
|---|---|
| protected SpreadsheetVersion getSpreadsheetVersion() Implements abstract org. Doc from org. Get the spreadsheet version for the given implementation.
| |
| getStringCellValue | back to summary |
|---|---|
| public String getStringCellValue() Implements org. get the value of the cell as a string - 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
| |
| isPartOfArrayFormulaGroup | back to summary |
|---|---|
| public boolean isPartOfArrayFormulaGroup() Implements org.
| |
| notifyFormulaChanging | back to summary |
|---|---|
| private void notifyFormulaChanging() Should be called any time that a formula could potentially be deleted. Does nothing if this cell currently does not hold a formula | |
| readValue | back to summary |
|---|---|
| private CellValue readValue() | |
| removeCellComment | back to summary |
|---|---|
| public void removeCellComment() Implements org. Removes the comment for this cell, if there is one. WARNING - some versions of excel will loose all comments after performing this action!
| |
| removeFormulaImpl | back to summary |
|---|---|
| protected void removeFormulaImpl() Implements abstract org. Doc from org. Implementation-specific removal of the formula. The cell is guaranteed to have a regular formula set. Shall preserve the "cached" value.
| |
| removeHyperlink | back to summary |
|---|---|
| public void removeHyperlink() Implements org. Removes the hyperlink for this cell, if there is one.
| |
| restoreValue | back to summary |
|---|---|
| private void restoreValue(CellValue value) | |
| setAsActiveCell | back to summary |
|---|---|
| public void setAsActiveCell() Implements org. Doc from org. Sets this cell as the active cell for the worksheet
| |
| setCellArrayFormula | back to summary |
|---|---|
| pack-priv void setCellArrayFormula(CellRangeAddress range) | |
| setCellComment | back to summary |
|---|---|
| public void setCellComment(Comment comment) Implements org. Assign a comment to this cell. If the supplied comment is null, the comment for this cell will be removed. | |
| setCellErrorValue | back to summary |
|---|---|
| public void setCellErrorValue(byte errorCode) Implements org. Deprecated 3.15 beta 2. Use set an error value for the cell
| |
| setCellErrorValue | back to summary |
|---|---|
| public void setCellErrorValue(FormulaError error) set an error value for the cell
| |
| setCellFormulaImpl | back to summary |
|---|---|
| protected void setCellFormulaImpl(String formula) Implements abstract org. Doc from org. Implementation-specific setting the formula. Formula is not null. Shall not change the value. | |
| setCellStyle | back to summary |
|---|---|
| public void setCellStyle(CellStyle style) Implements org. Set the style for the cell. The style should be an HSSFCellStyle created/retrieved from the HSSFWorkbook. To change the style of a cell without affecting other cells that use the same style,
use
| |
| setCellStyle | back to summary |
|---|---|
| public void setCellStyle(HSSFCellStyle style) | |
| setCellType | back to summary |
|---|---|
| private void setCellType(CellType cellType, boolean setValue, int row, short col, short styleIndex) sets the cell type. The setValue flag indicates whether to bother about trying to preserve the current value in the new record if one is created. The @see #setCellValue method will call this method with false in setValue since it will overwrite the cell value later | |
| setCellTypeImpl | back to summary |
|---|---|
| protected void setCellTypeImpl(CellType cellType) Implements abstract org. Doc from org. Implementation-specific logic | |
| setCellValue | back to summary |
|---|---|
| public void setCellValue(boolean value) Implements org. set a boolean value for the cell
| |
| setCellValueImpl | back to summary |
|---|---|
| protected void setCellValueImpl(double value) Implements abstract org. Doc from org. Implementation-specific way to set a numeric value.
| |
| setCellValueImpl | back to summary |
|---|---|
| protected void setCellValueImpl(Date value) Implements abstract org. Doc from org. Implementation-specific way to set a date value.
In HSSF, only the number of days is stored. The fractional part is ignored.
| |
| setCellValueImpl | back to summary |
|---|---|
| protected void setCellValueImpl(LocalDateTime value) Implements abstract org. Doc from org. Implementation-specific way to set a date value.
In HSSF, only the number of days is stored. The fractional part is ignored.
| |
| setCellValueImpl | back to summary |
|---|---|
| protected void setCellValueImpl(Calendar value) Implements abstract org. Doc from org. Implementation-specific way to set a calendar value.
| |
| setCellValueImpl | back to summary |
|---|---|
| protected void setCellValueImpl(String value) Implements abstract org. Doc from org. Implementation-specific way to set a string value.
The value is guaranteed to be non-null and to satisfy the length limitation imposed by the spreadsheet version.
The implementation is expected to adjust cell type accordingly, so that after this call
getCellType() or getCachedFormulaResultType() (whichever appropriate) would return | |
| setCellValueImpl | back to summary |
|---|---|
| protected void setCellValueImpl(RichTextString value) Implements abstract org. Doc from org. Implementation-specific way to set a RichTextString value.
The value is guaranteed to be non-null, having non-null value, and to satisfy the length limitation imposed
by the spreadsheet version.
The implementation is expected to adjust cell type accordingly, so that after this call
getCellType() or getCachedFormulaResultType() (whichever appropriate) would return
| |
| setHyperlink | back to summary |
|---|---|
| public void setHyperlink(Hyperlink hyperlink) Implements org. Assign a hyperlink to this cell. If the supplied hyperlink is null, the hyperlink for this cell will be removed. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. 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. 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>
| |
| typeMismatch | back to summary |
|---|---|
| private static RuntimeException typeMismatch(CellType expectedTypeCode, CellType actualTypeCode, boolean isFormulaCell) | |
| updateCellNum | back to summary |
|---|---|
| protected void updateCellNum(short num) Updates the cell record's idea of what column it belongs in (0 based)
| |