Represents a Workbook. Contains the various factory methods and provides
a variety of accessors which provide access to the work sheets.
close
public abstract void close()
Closes this workbook, and frees makes any memory allocated available
for garbage collection
createWorkbook
public static WritableWorkbook createWorkbook(OutputStream os)
throws IOException
Creates a writable workbook. When the workbook is closed,
it will be streamed directly to the output stream. In this
manner, a generated excel spreadsheet can be passed from
a servlet to the browser over HTTP
createWorkbook
public static WritableWorkbook createWorkbook(OutputStream os,
Workbook in)
throws IOException
Creates a writable workbook as a copy of
the workbook passed in. Once created, the contents of the writable
workbook may be modified
os
- the stream to write toin
- the workbook to copy
createWorkbook
public static WritableWorkbook createWorkbook(OutputStream os,
Workbook in,
WorkbookSettings ws)
throws IOException
Creates a writable workbook as a copy of
the workbook passed in. Once created, the contents of the writable
workbook may be modified
os
- the output stream to write toin
- the workbook to copyws
- the configuration for this workbook
createWorkbook
public static WritableWorkbook createWorkbook(OutputStream os,
WorkbookSettings ws)
throws IOException
Creates a writable workbook. When the workbook is closed,
it will be streamed directly to the output stream. In this
manner, a generated excel spreadsheet can be passed from
a servlet to the browser over HTTP
os
- the output streamws
- the configuration for this workbook
createWorkbook
public static WritableWorkbook createWorkbook(java.io.File file)
throws IOException
Creates a writable workbook with the given file name
file
- the workbook to copy
createWorkbook
public static WritableWorkbook createWorkbook(java.io.File file,
Workbook in)
throws IOException
Creates a writable workbook with the given filename as a copy of
the workbook passed in. Once created, the contents of the writable
workbook may be modified
file
- the output file for the copyin
- the workbook to copy
createWorkbook
public static WritableWorkbook createWorkbook(java.io.File file,
Workbook in,
WorkbookSettings ws)
throws IOException
Creates a writable workbook with the given filename as a copy of
the workbook passed in. Once created, the contents of the writable
workbook may be modified
file
- the output file for the copyin
- the workbook to copyws
- the configuration for this workbook
createWorkbook
public static WritableWorkbook createWorkbook(java.io.File file,
WorkbookSettings ws)
throws IOException
Creates a writable workbook with the given file name
file
- the file to copy fromws
- the global workbook settings
findByName
public abstract Range[] findByName(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
name
- the name of the cell/range to search for
- the range of cells, or NULL if the range does not exist
findCellByName
public abstract Cell findCellByName(String name)
Gets the named cell from this workbook. If the name refers to a
range of cells, then the cell on the top left is returned. If
the name cannot be found, null is returned.
This is a convenience function to quickly access the contents
of a single cell. If you need further information (such as the
sheet or adjacent cells in the range) use the functionally
richer method, findByName which returns a list of ranges
name
- the name of the cell/range to search for
- the cell in the top left of the range if found, NULL
otherwise
getCell
public abstract Cell getCell(String loc)
Returns the cell for the specified location eg. "Sheet1!A4".
This is identical to using the CellReferenceHelper with its
associated performance overheads, consequently it should
be use sparingly
loc
- the cell to retrieve
- the cell at the specified location
getNumberOfSheets
public abstract int getNumberOfSheets()
Returns the number of sheets in this workbook
- the number of sheets in this workbook
getRangeNames
public abstract String[] getRangeNames()
Gets the named ranges
- the list of named cells within the workbook
getSheet
public abstract Sheet getSheet(String name)
Gets the sheet with the specified name from within this workbook.
As described in the accompanying technical notes, each call
to getSheet forces a reread of the sheet (for memory reasons).
Therefore, do not make unnecessary calls to this method. Furthermore,
do not hold unnecessary references to Sheets in client code, as
this will prevent the garbage collector from freeing the memory
- The sheet with the specified name, or null if it is not found
getSheet
public abstract Sheet getSheet(int index)
throws IndexOutOfBoundsException
Gets the specified sheet within this workbook
As described in the accompanying technical notes, each call
to getSheet forces a reread of the sheet (for memory reasons).
Therefore, do not make unnecessary calls to this method. Furthermore,
do not hold unnecessary references to Sheets in client code, as
this will prevent the garbage collector from freeing the memory
index
- the zero based index of the reQuired sheet
- The sheet specified by the index
getSheetNames
public abstract String[] getSheetNames()
Gets the sheet names
- an array of strings containing the sheet names
getSheets
public abstract Sheet[] getSheets()
Gets the sheets within this workbook. Use of this method for
large worksheets can cause performance problems.
- an array of the individual sheets
getVersion
public static String getVersion()
Accessor for the software version
getWorkbook
public static Workbook getWorkbook(InputStream is)
throws IOException,
jxl.read.biff.BiffException
A factory method which takes in an excel file and reads in the contents.
is
- an open stream which is the the excel 97 spreadsheet to parse
jxl.read.biff.BiffException
-
getWorkbook
public static Workbook getWorkbook(InputStream is,
WorkbookSettings ws)
throws IOException,
jxl.read.biff.BiffException
A factory method which takes in an excel file and reads in the contents.
is
- an open stream which is the the excel 97 spreadsheet to parsews
- the settings for the workbook
jxl.read.biff.BiffException
-
getWorkbook
public static Workbook getWorkbook(java.io.File file)
throws IOException,
jxl.read.biff.BiffException
A factory method which takes in an excel file and reads in the contents.
file
- the excel 97 spreadsheet to parse
jxl.read.biff.BiffException
-
getWorkbook
public static Workbook getWorkbook(java.io.File file,
WorkbookSettings ws)
throws IOException,
jxl.read.biff.BiffException
A factory method which takes in an excel file and reads in the contents.
file
- the excel 97 spreadsheet to parsews
- the settings for the workbook
jxl.read.biff.BiffException
-
isProtected
public abstract boolean isProtected()
Determines whether the sheet is protected
- TRUE if the workbook is protected, FALSE otherwise