Save This Page
Home » poi-src-3.2-FINAL-20081019 » org.apache » poi » hssf » usermodel » [javadoc | source]
org.apache.poi.hssf.usermodel
public class: HSSFCell [javadoc | source]
java.lang.Object
   org.apache.poi.hssf.usermodel.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
public static final  int CELL_TYPE_NUMERIC    Numeric Cell type (0) 
public static final  int CELL_TYPE_STRING    String Cell type (1) 
public static final  int CELL_TYPE_FORMULA    Formula Cell type (2) 
public static final  int CELL_TYPE_BLANK    Blank Cell type (3) 
public static final  int CELL_TYPE_BOOLEAN    Boolean Cell type (4) 
public static final  int CELL_TYPE_ERROR    Error Cell type (5) 
public static final  short ENCODING_UNCHANGED     
public static final  short ENCODING_COMPRESSED_UNICODE     
public static final  short ENCODING_UTF_16     
Constructor:
 protected HSSFCell(HSSFWorkbook book,
    Sheet 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 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.

    Parameters:
    book - - Workbook record of the workbook containing this cell
    sheet - - Sheet record of the sheet containing this cell
    row - - the row of this cell
    col - - the column for this cell
    Also see:
    org.apache.poi.hssf.usermodel.HSSFRow#createCell(short)
 protected HSSFCell(HSSFWorkbook book,
    Sheet sheet,
    int row,
    CellValueRecordInterface cval) 
    Creates an HSSFCell from a CellValueRecordInterface. HSSFSheet uses this when reading in cells from an existing sheet.
    Parameters:
    book - - Workbook record of the workbook containing this cell
    sheet - - Sheet record of the sheet containing this cell
    cval - - the Cell Value Record we wish to represent
 protected HSSFCell(HSSFWorkbook book,
    Sheet sheet,
    int row,
    short col,
    int type) 
    Creates new Cell - Should only be called by HSSFRow. This creates a cell from scratch.
    Parameters:
    book - - Workbook record of the workbook containing this cell
    sheet - - Sheet record of the sheet containing this cell
    row - - the row of this cell
    col - - the column for this cell
    type - - CELL_TYPE_NUMERIC, CELL_TYPE_STRING, CELL_TYPE_FORMULA, CELL_TYPE_BLANK, CELL_TYPE_BOOLEAN, CELL_TYPE_ERROR Type of cell
    Also see:
    org.apache.poi.hssf.usermodel.HSSFRow#createCell(short,int)
Method from org.apache.poi.hssf.usermodel.HSSFCell Summary:
findCellComment,   getBooleanCellValue,   getBoundWorkbook,   getCellComment,   getCellFormula,   getCellNum,   getCellStyle,   getCellType,   getCellValueRecord,   getDateCellValue,   getEncoding,   getErrorCellValue,   getHyperlink,   getNumericCellValue,   getRichStringCellValue,   getStringCellValue,   setAsActiveCell,   setCellComment,   setCellErrorValue,   setCellFormula,   setCellNum,   setCellStyle,   setCellType,   setCellValue,   setCellValue,   setCellValue,   setCellValue,   setCellValue,   setCellValue,   setEncoding,   setHyperlink,   toString,   updateCellNum
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.poi.hssf.usermodel.HSSFCell Detail:
 protected static HSSFComment findCellComment(Sheet sheet,
    int row,
    int column) 
    Cell comment finder. Returns cell comment for the specified sheet, row and column.
 public boolean getBooleanCellValue() 
    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.
 protected Workbook getBoundWorkbook() 
    Returns the Workbook that this Cell is bound to
 public HSSFComment getCellComment() 
    Returns comment associated with this cell
 public String getCellFormula() 
 public short getCellNum() 
    get the cell's number within the row
 public HSSFCellStyle getCellStyle() 
    get the style for the cell. This is a reference to a cell style contained in the workbook object.
 public int getCellType() 
    get the cells type (numeric, formula or string)
 protected CellValueRecordInterface getCellValueRecord() 
    Should only be used by HSSFSheet and friends. Returns the low level CellValueRecordInterface record
 public Date getDateCellValue() 
    get the value of the cell as a date. For strings we throw an exception. For blank cells we return a null.
 public short getEncoding() 
Deprecated! As - of 3-Jan-06 POI now automatically handles Unicode without forcing the encoding.

    used for internationalization, currently -1 for unchanged, 0 for compressed unicode or 1 for 16-bit
 public byte getErrorCellValue() 
    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.
 public HSSFHyperlink getHyperlink() 
    Returns hyperlink associated with this cell
 public double getNumericCellValue() 
    get the value of the cell as a number. For strings we throw an exception. For blank cells we return a 0.
 public HSSFRichTextString getRichStringCellValue() 
    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 return empty String
 public String getStringCellValue() 
Deprecated! Use - the HSSFRichTextString return

    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 return empty String
 public  void setAsActiveCell() 
    Sets this cell as the active cell for the worksheet
 public  void setCellComment(HSSFComment comment) 
    Assign a comment to this cell
 public  void setCellErrorValue(byte value) 
    set a error value for the cell
 public  void setCellFormula(String formula) 
 public  void setCellNum(short num) 
Deprecated! Doesn - 't update the row's idea of what cell this is, use HSSFRow#moveCell(HSSFCell, short) instead

    Set the cell's number within the row (0 based).
 public  void setCellStyle(HSSFCellStyle style) 
    set the style for the cell. The style should be an HSSFCellStyle created/retreived from the HSSFWorkbook.
 public  void setCellType(int cellType) 
    set the cells type (numeric, formula or string)
 public  void setCellValue(double value) 
    set a numeric value for the cell
 public  void setCellValue(Date value) 
    set a date value for the cell. Excel treats dates as numeric so you will need to format the cell as a date.
 public  void setCellValue(Calendar value) 
    set a date value for the cell. Excel treats dates as numeric so you will need to format the cell as a date. This will set the cell value based on the Calendar's timezone. As Excel does not support timezones this means that both 20:00+03:00 and 20:00-03:00 will be reported as the same value (20:00) even that there are 6 hours difference between the two times. This difference can be preserved by using setCellValue(value.getTime()) which will automatically shift the times to the default timezone.
 public  void setCellValue(String value) 
Deprecated! Use - setCellValue(HSSFRichTextString) instead.

    set a string value for the cell. Please note that if you are using full 16 bit unicode you should call setEncoding() first.
 public  void setCellValue(HSSFRichTextString value) 
    set a string value for the cell. Please note that if you are using full 16 bit unicode you should call setEncoding() first.
 public  void setCellValue(boolean value) 
    set a boolean value for the cell
 public  void setEncoding(short encoding) 
Deprecated! As - of 3-Jan-06 POI now automatically handles Unicode without forcing the encoding.

    set the encoding to either 8 or 16 bit. (US/UK use 8-bit, rest of the western world use 16bit)
 public  void setHyperlink(HSSFHyperlink link) 
    Assign a hypelrink to this cell
 public 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. 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>
 protected  void updateCellNum(short num) 
    Updates the cell record's idea of what column it belongs in (0 based)