Save This Page
Home » cocoon-2.1.11-src » org.apache.cocoon.poi » hssf » model » [javadoc | source]
org.apache.cocoon.poi.hssf.model
public class: Sheet [javadoc | source]
java.lang.Object
   org.apache.cocoon.poi.hssf.model.Sheet
Low level model implementation of a Sheet (one workbook contains many sheets) This file contains the low level binary records starting at the sheets BOF and ending with the sheets EOF. Use HSSFSheet for a high level representation.

The structures of the highlevel API use references to this to perform most of their operations. Its probably unwise to use these low level structures directly unless you really know what you're doing. I recommend you read the Microsoft Excel 97 Developer's Kit (Microsoft Press) and the documentation at http://sc.openoffice.org/excelfileformat.pdf before even attempting to use this.

Field Summary
protected  ArrayList records     
 int preoffset     
 int loc     
protected  boolean containsLabels     
protected  int dimsloc     
protected  DimensionsRecord dims     
protected  DefaultColWidthRecord defaultcolwidth     
protected  DefaultRowHeightRecord defaultrowheight     
Constructor:
 public Sheet() 
Method from org.apache.cocoon.poi.hssf.model.Sheet Summary:
addDBCellRecords,   addRow,   addValueRecord,   checkDimsLoc,   convertLabelRecords,   createBOF,   createBlank,   createCalcCount,   createCalcMode,   createColInfo,   createDefaultColWidth,   createDefaultRowHeight,   createDelta,   createDimensions,   createEOF,   createFooter,   createFormula,   createGridset,   createGuts,   createHCenter,   createHeader,   createIndex,   createIteration,   createLabelSST,   createNumber,   createPrintGridlines,   createPrintHeaders,   createPrintSetup,   createRefMode,   createRow,   createSaveRecalc,   createSelection,   createSheet,   createSheet,   createSheet,   createVCenter,   createWSBool,   createWindowTwo,   getColumnWidth,   getDefaultColumnWidth,   getDefaultRowHeight,   getDimsLoc,   getLoc,   getNextRow,   getNextRowOrValue,   getNextValueRecord,   getNumRecords,   getPreOffset,   getRow,   removeRow,   removeValueRecord,   replaceValueRecord,   serialize,   setColumnWidth,   setDefaultColumnWidth,   setDefaultRowHeight,   setDimensions,   setLoc,   setPreOffset
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.cocoon.poi.hssf.model.Sheet Detail:
 public  void addDBCellRecords() 
    Not currently used method to calculate and add dbcell records
 public  void addRow(RowRecord row) 
    Adds a row record to the sheet

    This method is "loc" sensitive. Meaning you need to set LOC to where you want it to start searching. If you don't know do this: setLoc(getDimsLoc). When adding several rows you can just start at the last one by leaving loc at what this sets it to.

 public  void addValueRecord(short row,
    CellValueRecordInterface col) 
    Adds a value record to the sheet's contained binary records (i.e. LabelSSTRecord or NumberRecord).

    This method is "loc" sensitive. Meaning you need to set LOC to where you want it to start searching. If you don't know do this: setLoc(getDimsLoc). When adding several rows you can just start at the last one by leaving loc at what this sets it to.

 public  void checkDimsLoc(Record rec,
    int recloc) 
    in the event the record is a dimensions record, resets both the loc index and dimsloc index
 public  void convertLabelRecords(Workbook wb) 
    This is basically a kludge to deal with the now obsolete Label records. If you have to read in a sheet that contains Label records, be aware that the rest of the API doesn't deal with them, the low level structure only provides read-only semi-immutable structures (the sets are there for interface conformance with NO impelmentation). In short, you need to call this function passing it a reference to the Workbook object. All labels will be converted to LabelSST records and their contained strings will be written to the Shared String tabel (SSTRecord) within the Workbook.
 protected Record createBOF() 
    creates the BOF record
 public BlankRecord createBlank(short row,
    short col) 
    create a BLANK record (does not add it to the records contained in this sheet)
 protected Record createCalcCount() 
    creates the CalcCount record and sets it to 0x64 (default number of iterations)
 protected Record createCalcMode() 
    creates the CalcMode record and sets it to 1 (automatic formula caculation)
 protected Record createColInfo() 
    creates the ColumnInfo Record and sets it to a default column/width
 protected Record createDefaultColWidth() 
    creates the DefaultColWidth Record and sets it to 8
 protected Record createDefaultRowHeight() 
    creates the DefaultRowHeight Record and sets its options to 0 and rowheight to 0xff
 protected Record createDelta() 
    creates the Delta record and sets it to 0.0010 (default accuracy)
 protected Record createDimensions() 
    creates the Dimensions Record and sets it to bogus values (you should set this yourself or let the high level API do it for you)
 protected Record createEOF() 
    creates the EOF record
 protected Record createFooter() 
    creates the Footer Record and sets it to nothing/0 length
 public FormulaRecord createFormula(short row,
    short col,
    String formula) 
    Attempts to parse the formula into PTGs and create a formula record DOES NOT WORK YET
 protected Record createGridset() 
    creates the Gridset record and sets it to true (user has mucked with the gridlines)
 protected Record createGuts() 
    creates the Guts record and sets leftrow/topcol guttter and rowlevelmax/collevelmax to 0
 protected Record createHCenter() 
    creates the HCenter Record and sets it to false (don't horizontally center)
 protected Record createHeader() 
    creates the Header Record and sets it to nothing/0 length
 protected Record createIndex() 
    creates the Index record - not currently used
 protected Record createIteration() 
    creates the Iteration record and sets it to false (don't iteratively calculate formulas)
 public LabelSSTRecord createLabelSST(short row,
    short col,
    int index) 
    Create a LABELSST Record (does not add it to the records contained in this sheet)
 public NumberRecord createNumber(short row,
    short col,
    double value) 
    Create a NUMBER Record (does not add it to the records contained in this sheet)
 protected Record createPrintGridlines() 
    creates the PrintGridlines record and sets it to false (that makes for ugly sheets)
 protected Record createPrintHeaders() 
    creates the PrintHeaders record and sets it to false (we don't create headers yet so why print them)
 protected Record createPrintSetup() 
    creates the PrintSetup Record and sets it to defaults and marks it invalid
 protected Record createRefMode() 
    creates the RefMode record and sets it to A1 Mode (default reference mode)
 public RowRecord createRow(int row) 
    Create a row record. (does not add it to the records contained in this sheet)
 protected Record createSaveRecalc() 
    creates the SaveRecalc record and sets it to true (recalculate before saving)
 protected Record createSelection() 
    Creates the Selection record and sets it to nothing selected
 public static Sheet createSheet() 
    Creates a sheet with all the usual records minus values and the "index" record (not required). Sets the location pointer to where the first value records should go. Use this to create a sheet from "scratch".
 public static Sheet createSheet(Record[] records,
    int sheetnum) 
    read support (offset = 0) Same as createSheet(Record[] recs, int, int) only the record offset is assumed to be 0.
 public static Sheet createSheet(Record[] recs,
    int sheetnum,
    int offset) 
    read support (offset used as starting point for search) for low level API. Pass in an array of Record objects, the sheet number (0 based) and a record offset (should be the location of the sheets BOF record). A Sheet object is constructed and passed back with all of its initialization set to the passed in records and references to those records held. This function is normally called via Workbook.
 protected Record createVCenter() 
    creates the VCenter Record and sets it to false (don't horizontally center)
 protected Record createWSBool() 
    creates the WSBoolRecord and sets its values to defaults
 protected Record createWindowTwo() 
    creates the WindowTwo Record and sets it to:

    options = 0x6b6

    toprow = 0

    leftcol = 0

    headercolor = 0x40

    pagebreakzoom = 0x0

    normalzoom = 0x0

 public short getColumnWidth(short column) 
    get the width of a given column in units of 1/20th of a point width (twips?)
 public short getDefaultColumnWidth() 
    get the default column width for the sheet (if the columns do not define their own width)
 public short getDefaultRowHeight() 
    get the default row height for the sheet (if the rows do not define their own height)
 public int getDimsLoc() 
    get the location of the DimensionsRecord (which is the last record before the value section)
 public int getLoc() 
    Returns the location pointer to the first record to look for when adding rows/values
 public RowRecord getNextRow() 
    get the NEXT RowRecord (from LOC). The first record that is a Row record (starting at LOC) will be returned.

    This method is "loc" sensitive. Meaning you need to set LOC to where you want it to start searching. If you don't know do this: setLoc(getDimsLoc). When adding several rows you can just start at the last one by leaving loc at what this sets it to. For this method, set loc to dimsloc to start with. subsequent calls will return rows in (physical) sequence or NULL when you get to the end.

 public Record getNextRowOrValue() 
    get the NEXT RowRecord or CellValueRecord(from LOC). The first record that is a Row record or CellValueRecord(starting at LOC) will be returned.

    This method is "loc" sensitive. Meaning you need to set LOC to where you want it to start searching. If you don't know do this: setLoc(getDimsLoc). When adding several rows you can just start at the last one by leaving loc at what this sets it to. For this method, set loc to dimsloc to start with. subsequent calls will return rows in (physical) sequence or NULL when you get to the end.

 public CellValueRecordInterface getNextValueRecord() 
    get the NEXT value record (from LOC). The first record that is a value record (starting at LOC) will be returned.

    This method is "loc" sensitive. Meaning you need to set LOC to where you want it to start searching. If you don't know do this: setLoc(getDimsLoc). When adding several rows you can just start at the last one by leaving loc at what this sets it to. For this method, set loc to dimsloc to start with, subsequent calls will return values in (physical) sequence or NULL when you get to the end.

 public int getNumRecords() 
    Returns the number of low level binary records in this sheet.
 public int getPreOffset() 
    get the preoffset when using DBCELL records (currently unused) - this is the position of this sheet within the whole file.
 public RowRecord getRow(short rownum) 
    get the NEXT (from LOC) RowRecord where rownumber matches the given rownum. The first record that is a Row record (starting at LOC) that has the same rownum as the given rownum will be returned.

    This method is "loc" sensitive. Meaning you need to set LOC to where you want it to start searching. If you don't know do this: setLoc(getDimsLoc). When adding several rows you can just start at the last one by leaving loc at what this sets it to. For this method, set loc to dimsloc to start with. subsequent calls will return rows in (physical) sequence or NULL when you get to the end.

 public  void removeRow(RowRecord row) 
    Removes a row record This method is not loc sensitive, it resets loc to = dimsloc so no worries.
 public  void removeValueRecord(short row,
    CellValueRecordInterface col) 
    remove a value record from the records array. This method is not loc sensitive, it resets loc to = dimsloc so no worries.
 public  void replaceValueRecord(CellValueRecordInterface newval) 
    replace a value record from the records array. This method is not loc sensitive, it resets loc to = dimsloc so no worries.
 public byte[] serialize() 
    Serializes all records in the sheet into one big byte array. Use this to write the sheet out.
 public  void setColumnWidth(short column,
    short width) 
    set the width for a given column in 1/20th of a character width units
 public  void setDefaultColumnWidth(short dcw) 
    set the default column width for the sheet (if the columns do not define their own width)
 public  void setDefaultRowHeight(short dch) 
    set the default row height for the sheet (if the rows do not define their own height)
 public  void setDimensions(short firstrow,
    short firstcol,
    short lastrow,
    short lastcol) 
    Per an earlier reported bug in working with Andy Khan's excel read library. This sets the values in the sheet's DimensionsRecord object to be correct. Excel doesn't really care, but we want to play nice with other libraries.
 public  void setLoc(int loc) 
    set the locator for where we should look for the next value record. The algorythm will actually start here and find the correct location so you can set this to 0 and watch performance go down the tubes but it will work. After a value is set this is automatically advanced. Its also set by the create method. So you probably shouldn't mess with this unless you have a compelling reason why or the help for the method you're calling says so. Check the other methods for whether they care about the loc pointer. Many of the "modify" and "remove" methods re-initialize this to "dimsloc" which is the location of the Dimensions Record and presumably the start of the value section (at or around 19 dec).
 public  void setPreOffset(int offset) 
    Set the preoffset when using DBCELL records (currently unused) - this is the position of this sheet within the whole file.