jxl.read.biff
Class WorkbookParser

java.lang.Object
  |
  +--jxl.Workbook
        |
        +--jxl.read.biff.WorkbookParser
All Implemented Interfaces:
ExternalSheet, NameTable

public class WorkbookParser
extends Workbook
implements ExternalSheet, NameTable

Parses the biff file passed in, and builds up an internal representation of the spreadsheet


Field Summary
private  int bofs
          The number of open bofs
private  java.util.ArrayList boundsheets
          The names of all the worksheets
private  File excelFile
          The excel file
private  ExternalSheetRecord externSheet
          The external sheet record.
private  Fonts fonts
          The fonts used by this workbook
private  FormattingRecords formattingRecords
          The xf records
private  SheetImpl lastSheet
          The last sheet accessed
private  int lastSheetIndex
          The index of the last sheet retrieved
private  MsoDrawingGroupRecord msoDrawingGroup
          The Mso Drawing Group record for this workbook
private  java.util.HashMap namedRecords
          The named records found in this workbook
private  java.lang.String[] names
          The list of named records
private  boolean nineteenFour
          Indicates whether or not the dates are based around the 1904 date system
private  WorkbookSettings settings
          The workbook settings
private  SSTRecord sharedStrings
          The shared string table
private  java.util.ArrayList sheets
          The sheets contained in this workbook
private  java.util.ArrayList supbooks
          The list of supporting workbooks - used by formulas
private  boolean wbProtected
          Workbook protected flag
private  BOFRecord workbookBof
          The bof record for this workbook
 
Fields inherited from class jxl.Workbook
version
 
Constructor Summary
WorkbookParser(File f, WorkbookSettings s)
          Constructs this object from the raw excel data
 
Method Summary
(package private)  void addSheet(Sheet s)
          Adds the sheet to the end of the array
 void close()
          Closes this workbook, and frees makes any memory allocated available for garbage collection
 Range[] findByName(java.lang.String name)
          Gets the named range from this workbook.
 Cell findCellByName(java.lang.String name)
          Gets the named cell from this workbook.
(package private)  int getExternalSheetIndex(int index)
          Package protected function which gets the real internal sheet index based upon the external sheet reference.
 int getExternalSheetIndex(java.lang.String sheetName)
          Accessor/implementation method for the external sheet reference
 java.lang.String getExternalSheetName(int index)
          Gets the name of the external sheet specified by the index
 ExternalSheetRecord getExternalSheetRecord()
          Accessor for the externSheet, used by the WritableWorkbook when creating a copy of this
 Fonts getFonts()
          Accessor for the fonts, used by the WritableWorkbook when creating a copy of this
 FormattingRecords getFormattingRecords()
          Accessor for the formattingRecords, used by the WritableWorkbook when creating a copy of this
 MsoDrawingGroupRecord getMsoDrawingGroupRecord()
          Accessor for the MsoDrawingGroup, used by the WritableWorkbook when creating a copy of this
 java.lang.String getName(int index)
          Gets the name at the specified index
 int getNameIndex(java.lang.String name)
          Gets the index of the name record for the name
 NameRecord[] getNameRecords()
          Accessor for the name records.
 int getNumberOfSheets()
          Returns the number of sheets in this workbook
 WorkbookSettings getSettings()
          Accessor for the settings
 Sheet getSheet(int index)
          Gets the specified sheet within this workbook
 Sheet getSheet(java.lang.String name)
          Gets the sheet with the specified name from within this workbook
 Sheet[] getSheets()
          Gets the sheets within this workbook.
 SupbookRecord[] getSupbookRecords()
          Accessor for the supbook records, used by the WritableWorkbook when creating a copy of this
 BOFRecord getWorkbookBof()
          Method used when parsing formulas to make sure we are trying to parse a supported biff version
 boolean isProtected()
          Determines whether the sheet is protected
protected  void parse()
          Does the hard work of building up the object graph from the excel bytes
 
Methods inherited from class jxl.Workbook
createWorkbook, createWorkbook, createWorkbook, createWorkbook, createWorkbook, createWorkbook, createWorkbook, createWorkbook, getVersion, getWorkbook, getWorkbook, getWorkbook, getWorkbook
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

excelFile

private File excelFile
The excel file

bofs

private int bofs
The number of open bofs

nineteenFour

private boolean nineteenFour
Indicates whether or not the dates are based around the 1904 date system

sharedStrings

private SSTRecord sharedStrings
The shared string table

boundsheets

private java.util.ArrayList boundsheets
The names of all the worksheets

formattingRecords

private FormattingRecords formattingRecords
The xf records

fonts

private Fonts fonts
The fonts used by this workbook

sheets

private java.util.ArrayList sheets
The sheets contained in this workbook

lastSheet

private SheetImpl lastSheet
The last sheet accessed

lastSheetIndex

private int lastSheetIndex
The index of the last sheet retrieved

namedRecords

private java.util.HashMap namedRecords
The named records found in this workbook

names

private java.lang.String[] names
The list of named records

externSheet

private ExternalSheetRecord externSheet
The external sheet record. Used by formulas, and names

supbooks

private java.util.ArrayList supbooks
The list of supporting workbooks - used by formulas

workbookBof

private BOFRecord workbookBof
The bof record for this workbook

msoDrawingGroup

private MsoDrawingGroupRecord msoDrawingGroup
The Mso Drawing Group record for this workbook

wbProtected

private boolean wbProtected
Workbook protected flag

settings

private WorkbookSettings settings
The workbook settings
Constructor Detail

WorkbookParser

public WorkbookParser(File f,
                      WorkbookSettings s)
Constructs this object from the raw excel data
Parameters:
f - the excel 97 biff file
s - the workbook settings
Method Detail

getSheets

public Sheet[] getSheets()
Gets the sheets within this workbook. NOTE: Use of this method for very large worksheets can cause performance and out of memory problems. Use the alternative method getSheet() to retrieve each sheet individually
Overrides:
getSheets in class Workbook
Returns:
an array of the individual sheets

getSheet

public Sheet getSheet(int index)
Gets the specified sheet within this workbook
Overrides:
getSheet in class Workbook
Parameters:
index - the zero based index of the required sheet
Returns:
The sheet specified by the index

getSheet

public Sheet getSheet(java.lang.String name)
Gets the sheet with the specified name from within this workbook
Overrides:
getSheet in class Workbook
Parameters:
name - the sheet name
Returns:
The sheet with the specified name, or null if it is not found

getExternalSheetIndex

int getExternalSheetIndex(int index)
Package protected function which gets the real internal sheet index based upon the external sheet reference. This is used for extern sheet references which are specified in formulas
Parameters:
index - the external sheet reference
Returns:
the actual sheet index

getExternalSheetName

public java.lang.String getExternalSheetName(int index)
Gets the name of the external sheet specified by the index
Specified by:
getExternalSheetName in interface ExternalSheet
Parameters:
index - the external sheet index
Returns:
the name of the external sheet

getNumberOfSheets

public int getNumberOfSheets()
Returns the number of sheets in this workbook
Overrides:
getNumberOfSheets in class Workbook
Returns:
the number of sheets in this workbook

close

public void close()
Closes this workbook, and frees makes any memory allocated available for garbage collection
Overrides:
close in class Workbook

addSheet

final void addSheet(Sheet s)
Adds the sheet to the end of the array
Parameters:
s - the sheet to add

parse

protected void parse()
              throws BiffException,
                     PasswordException
Does the hard work of building up the object graph from the excel bytes
Overrides:
parse in class Workbook
Throws:
BiffException -  
PasswordException - if the workbook is password protected

getFormattingRecords

public FormattingRecords getFormattingRecords()
Accessor for the formattingRecords, used by the WritableWorkbook when creating a copy of this
Returns:
the formatting records

getExternalSheetRecord

public ExternalSheetRecord getExternalSheetRecord()
Accessor for the externSheet, used by the WritableWorkbook when creating a copy of this
Returns:
the external sheet record

getMsoDrawingGroupRecord

public MsoDrawingGroupRecord getMsoDrawingGroupRecord()
Accessor for the MsoDrawingGroup, used by the WritableWorkbook when creating a copy of this
Returns:
the Mso Drawing Group record

getSupbookRecords

public SupbookRecord[] getSupbookRecords()
Accessor for the supbook records, used by the WritableWorkbook when creating a copy of this
Returns:
the supbook records

getNameRecords

public NameRecord[] getNameRecords()
Accessor for the name records. Used by the WritableWorkbook when creating a copy of this
Returns:
the array of names

getFonts

public Fonts getFonts()
Accessor for the fonts, used by the WritableWorkbook when creating a copy of this

findCellByName

public Cell findCellByName(java.lang.String name)
Gets the named cell from this workbook. The name refers to a range of cells, then the cell on the top left is returned. If the name cannot be, null is returned
Overrides:
findCellByName in class Workbook
Parameters:
the - name of the cell/range to search for
Returns:
the cell in the top left of the range if found, NULL otherwise

findByName

public Range[] findByName(java.lang.String name)
Gets the named range from this workbook. The Range object returns contains all the cells from the top left to the bottom right of the range. If the named range comprises an adjacent range, the Range[] will contain one object; for non-adjacent ranges, it is necessary to return an array of length greater than one. If the named range contains a single cell, the top left and bottom right cell will be the same cell
Overrides:
findByName in class Workbook
Parameters:
the - name of the cell/range to search for
Returns:
the range of cells

getWorkbookBof

public BOFRecord getWorkbookBof()
Method used when parsing formulas to make sure we are trying to parse a supported biff version
Specified by:
getWorkbookBof in interface ExternalSheet
Returns:
the BOF record

isProtected

public boolean isProtected()
Determines whether the sheet is protected
Overrides:
isProtected in class Workbook
Returns:
whether or not the sheet is protected

getSettings

public WorkbookSettings getSettings()
Accessor for the settings
Returns:
the workbook settings

getExternalSheetIndex

public int getExternalSheetIndex(java.lang.String sheetName)
Accessor/implementation method for the external sheet reference
Specified by:
getExternalSheetIndex in interface ExternalSheet
Parameters:
sheetName -  
Returns:
the external sheet index

getName

public java.lang.String getName(int index)
Gets the name at the specified index
Specified by:
getName in interface NameTable
Parameters:
index - the index into the name table
Returns:
the name of the cell

getNameIndex

public int getNameIndex(java.lang.String name)
Gets the index of the name record for the name
Specified by:
getNameIndex in interface NameTable
Parameters:
name -  
Returns:
the index in the name table