jxl.read.biff
Class SheetImpl

java.lang.Object
  |
  +--jxl.read.biff.SheetImpl
All Implemented Interfaces:
Sheet

public class SheetImpl
extends java.lang.Object
implements Sheet

Represents a sheet within a workbook. Provides a handle to the individual cells, or lines of cells (grouped by Row or Column) In order to simplify this class due to code bloat, the actual reading logic has been delegated to the SheetReaderClass. This class' main responsibility is now to implement the API methods declared in the Sheet interface


Field Summary
private  Cell[][] cells
          The cells
private  java.util.ArrayList charts
          A list of charts on this page
private  ColumnInfoRecord[] columnInfos
          The list of specified (ie.
private  java.util.ArrayList columnInfosArray
          An array of column info records.
private  boolean columnInfosInitialized
          Indicates whether the columnInfos array has been initialized
private  File excelFile
          The excel file
private  FooterRecord footer
          The page footer
private  FormattingRecords formattingRecords
          A handle to the formatting records
private  HeaderRecord header
          The page header
private  boolean hidden
          The hidden flag
private  java.util.ArrayList hyperlinks
          A list of hyperlinks on this page
private  MergedCellsRecord mergedCells
          A list of merged cells on this page
private  java.lang.String name
          The name of this sheet
private  boolean nineteenFour
          Indicates whether or not the dates are based around the 1904 date system
private  int numCols
          The number of columns
private  int numRows
          The number of rows
private  int[] rowBreaks
          The horizontal page breaks contained on this sheet
private  java.util.ArrayList rowProperties
          The list of non-default row properties
private  RowRecord[] rowRecords
          The array of row records
private  boolean rowRecordsInitialized
          Indicates whether the rowRecords array has been initialized
private  SheetSettings settings
          The sheet settings
private  java.util.ArrayList sharedFormulas
          A list of shared formula groups
private  SSTRecord sharedStrings
          A handle to the shared string table
private  BOFRecord sheetBof
          A handle to the sheet BOF record, which indicates the stream type
private  int startPosition
          The start position in the stream of this sheet
private  WorkbookParser workbook
          A handle to the workbook which contains this sheet.
private  BOFRecord workbookBof
          A handle to the workbook BOF record, which indicates the stream type
private  WorkbookSettings workbookSettings
          A handle to the workbook settings
private  WorkspaceInformationRecord workspaceOptions
          The workspace options
 
Constructor Summary
(package private) SheetImpl(File f, SSTRecord sst, FormattingRecords fr, BOFRecord sb, BOFRecord wb, boolean nf, WorkbookParser wp)
          Constructor
 
Method Summary
(package private)  void clear()
          Clears out the array of cells.
 Cell findCell(java.lang.String contents)
          Gets the cell whose contents match the string passed in.
 LabelCell findLabelCell(java.lang.String contents)
          Gets the cell whose contents match the string passed in.
 Cell getCell(int column, int row)
          Returns the cell specified at this row and at this column
 Chart[] getCharts()
          Gets the charts.
 Cell[] getColumn(int col)
          Gets all the cells on the specified column.
 ColumnInfoRecord getColumnInfo(int col)
          Gets the column info record for the specified column.
 ColumnInfoRecord[] getColumnInfos()
          Gets all the column info records
 int getColumns()
          Returns the number of columns in this sheet
 FooterRecord getFooter()
          Gets the footer.
 HeaderRecord getHeader()
          Gets the header.
 Hyperlink[] getHyperlinks()
          Gets the hyperlinks on this sheet
 Range[] getMergedCells()
          Gets the cells which have been merged on this sheet
 java.lang.String getName()
          Gets the name of this sheet
 Cell[] getRow(int row)
          Gets all the cells on the specified row.
(package private)  RowRecord getRowInfo(int r)
          Gets the row record.
 int[] getRowPageBreaks()
          Gets the row breaks.
 RowRecord[] getRowProperties()
          Gets the non-default rows.
 int getRows()
          Returns the number of rows in this sheet
 SheetSettings getSettings()
          Accessor for the sheet settings
(package private)  WorkbookParser getWorkbook()
          Accessor for the workbook
 WorkspaceInformationRecord getWorkspaceOptions()
          Gets the workspace options for this sheet.
 boolean isHidden()
          Deprecated. in favour of the getSettings function
 boolean isProtected()
          Deprecated. in favour of the getSettings() api
(package private)  void readSheet()
          Reads in the contents of this sheet
(package private)  void setHidden(boolean h)
          Sets the visibility of this sheet
(package private)  void setName(java.lang.String s)
          Sets the name of this sheet
 
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

sharedStrings

private SSTRecord sharedStrings
A handle to the shared string table

sheetBof

private BOFRecord sheetBof
A handle to the sheet BOF record, which indicates the stream type

workbookBof

private BOFRecord workbookBof
A handle to the workbook BOF record, which indicates the stream type

formattingRecords

private FormattingRecords formattingRecords
A handle to the formatting records

name

private java.lang.String name
The name of this sheet

numRows

private int numRows
The number of rows

numCols

private int numCols
The number of columns

cells

private Cell[][] cells
The cells

startPosition

private int startPosition
The start position in the stream of this sheet

columnInfos

private ColumnInfoRecord[] columnInfos
The list of specified (ie. non default) column widths

rowRecords

private RowRecord[] rowRecords
The array of row records

rowProperties

private java.util.ArrayList rowProperties
The list of non-default row properties

columnInfosArray

private java.util.ArrayList columnInfosArray
An array of column info records. They are held this way before they are transferred to the more convenient array

sharedFormulas

private java.util.ArrayList sharedFormulas
A list of shared formula groups

hyperlinks

private java.util.ArrayList hyperlinks
A list of hyperlinks on this page

charts

private java.util.ArrayList charts
A list of charts on this page

mergedCells

private MergedCellsRecord mergedCells
A list of merged cells on this page

columnInfosInitialized

private boolean columnInfosInitialized
Indicates whether the columnInfos array has been initialized

rowRecordsInitialized

private boolean rowRecordsInitialized
Indicates whether the rowRecords array has been initialized

nineteenFour

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

header

private HeaderRecord header
The page header

footer

private FooterRecord footer
The page footer

workspaceOptions

private WorkspaceInformationRecord workspaceOptions
The workspace options

hidden

private boolean hidden
The hidden flag

settings

private SheetSettings settings
The sheet settings

rowBreaks

private int[] rowBreaks
The horizontal page breaks contained on this sheet

workbook

private WorkbookParser workbook
A handle to the workbook which contains this sheet. Some of the records need this in order to reference external sheets

workbookSettings

private WorkbookSettings workbookSettings
A handle to the workbook settings
Constructor Detail

SheetImpl

SheetImpl(File f,
          SSTRecord sst,
          FormattingRecords fr,
          BOFRecord sb,
          BOFRecord wb,
          boolean nf,
          WorkbookParser wp)
    throws BiffException
Constructor
Parameters:
fr -  
sst - the shared string table
f - the excel file
sb - the bof record which indicates the start of the sheet
wb - the bof record which indicates the start of the sheet
wp - the workbook which this sheet belongs to
Throws:
BiffException -  
Method Detail

getCell

public Cell getCell(int column,
                    int row)
Returns the cell specified at this row and at this column
Specified by:
getCell in interface Sheet
Parameters:
row - the row number
column - the column number
Returns:
the cell at the specified co-ordinates

findCell

public Cell findCell(java.lang.String contents)
Gets the cell whose contents match the string passed in. If no match is found, then null is returned. The search is performed on a row by row basis, so the lower the row number, the more efficiently the algorithm will perform
Specified by:
findCell in interface Sheet
Parameters:
contents - the string to match
Returns:
the Cell whose contents match the paramter, null if not found

findLabelCell

public LabelCell findLabelCell(java.lang.String contents)
Gets the cell whose contents match the string passed in. If no match is found, then null is returned. The search is performed on a row by row basis, so the lower the row number, the more efficiently the algorithm will perform. This method differs from the findCell methods in that only cells with labels are queried - all numerical cells are ignored. This should therefore improve performance.
Specified by:
findLabelCell in interface Sheet
Parameters:
contents - the string to match
Returns:
the Cell whose contents match the paramter, null if not found

getRows

public int getRows()
Returns the number of rows in this sheet
Specified by:
getRows in interface Sheet
Returns:
the number of rows in this sheet

getColumns

public int getColumns()
Returns the number of columns in this sheet
Specified by:
getColumns in interface Sheet
Returns:
the number of columns in this sheet

getRow

public Cell[] getRow(int row)
Gets all the cells on the specified row. The returned array will be stripped of all trailing empty cells
Specified by:
getRow in interface Sheet
Parameters:
row - the rows whose cells are to be returned
Returns:
the cells on the given row

getColumn

public Cell[] getColumn(int col)
Gets all the cells on the specified column. The returned array will be stripped of all trailing empty cells
Specified by:
getColumn in interface Sheet
Parameters:
col - the column whose cells are to be returned
Returns:
the cells on the specified column

getName

public java.lang.String getName()
Gets the name of this sheet
Specified by:
getName in interface Sheet
Returns:
the name of the sheet

setName

final void setName(java.lang.String s)
Sets the name of this sheet
Parameters:
s -  

isHidden

public boolean isHidden()
Deprecated. in favour of the getSettings function

Determines whether the sheet is hidden
Specified by:
isHidden in interface Sheet
Returns:
whether or not the sheet is hidden

getColumnInfo

public ColumnInfoRecord getColumnInfo(int col)
Gets the column info record for the specified column. If no column is specified, null is returned
Returns:
the ColumnInfoRecord if specified, NULL otherwise

getColumnInfos

public ColumnInfoRecord[] getColumnInfos()
Gets all the column info records
Returns:
the ColumnInfoRecordArray

setHidden

final void setHidden(boolean h)
Sets the visibility of this sheet
Parameters:
h -  

clear

final void clear()
Clears out the array of cells. This is done for memory allocation reasons when reading very large sheets

readSheet

final void readSheet()
Reads in the contents of this sheet

getHyperlinks

public Hyperlink[] getHyperlinks()
Gets the hyperlinks on this sheet
Specified by:
getHyperlinks in interface Sheet
Returns:
an array of hyperlinks

getMergedCells

public Range[] getMergedCells()
Gets the cells which have been merged on this sheet
Specified by:
getMergedCells in interface Sheet
Returns:
an array of range objects

getRowProperties

public RowRecord[] getRowProperties()
Gets the non-default rows. Used when copying spreadsheets
Returns:
an array of row properties

getRowInfo

RowRecord getRowInfo(int r)
Gets the row record. Usually called by the cell in the specified row in order to determine its size
Parameters:
r - the row
Returns:
the RowRecord for the specified row

getHeader

public final HeaderRecord getHeader()
Gets the header. Called when copying sheets
Returns:
the page header

getFooter

public final FooterRecord getFooter()
Gets the footer. Called when copying sheets
Returns:
the page footer

getRowPageBreaks

public final int[] getRowPageBreaks()
Gets the row breaks. Called when copying sheets
Returns:
the explicit row breaks

getCharts

public final Chart[] getCharts()
Gets the charts. Called when copying sheets
Returns:
the charts on this page

isProtected

public boolean isProtected()
Deprecated. in favour of the getSettings() api

Determines whether the sheet is protected
Specified by:
isProtected in interface Sheet
Returns:
whether or not the sheet is protected

getWorkspaceOptions

public WorkspaceInformationRecord getWorkspaceOptions()
Gets the workspace options for this sheet. Called during the copy process
Returns:
the workspace options

getSettings

public SheetSettings getSettings()
Accessor for the sheet settings
Specified by:
getSettings in interface Sheet
Returns:
the settings for this sheet

getWorkbook

WorkbookParser getWorkbook()
Accessor for the workbook