Represents a Workbook. Contains the various factory methods and provides
a variety of accessors which provide access to the work sheets.
| Method from jxl.Workbook Detail: |
abstract public void close()
Closes this workbook, and frees makes any memory allocated available
for garbage collection |
public static WritableWorkbook createWorkbook(File file) throws IOException {
return createWorkbook(file, new WorkbookSettings());
}
Creates a writable workbook with the given file name |
public static WritableWorkbook createWorkbook(OutputStream os) throws IOException {
return createWorkbook(os, new WorkbookSettings());
}
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 |
public static WritableWorkbook createWorkbook(File file,
WorkbookSettings ws) throws IOException {
FileOutputStream fos = new FileOutputStream(file);
WritableWorkbook w = new WritableWorkbookImpl(fos, true, ws);
return w;
}
Creates a writable workbook with the given file name |
public static WritableWorkbook createWorkbook(File file,
Workbook in) throws IOException {
return createWorkbook(file, in, new WorkbookSettings());
}
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 |
public static WritableWorkbook createWorkbook(OutputStream os,
Workbook in) throws IOException {
return createWorkbook(os, in, ((WorkbookParser) in).getSettings());
}
Creates a writable workbook as a copy of
the workbook passed in. Once created, the contents of the writable
workbook may be modified |
public static WritableWorkbook createWorkbook(OutputStream os,
WorkbookSettings ws) throws IOException {
WritableWorkbook w = new WritableWorkbookImpl(os, false, ws);
return w;
}
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 |
public static WritableWorkbook createWorkbook(File file,
Workbook in,
WorkbookSettings ws) throws IOException {
FileOutputStream fos = new FileOutputStream(file);
WritableWorkbook w = new WritableWorkbookImpl(fos, in, true, ws);
return w;
}
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 |
public static WritableWorkbook createWorkbook(OutputStream os,
Workbook in,
WorkbookSettings ws) throws IOException {
WritableWorkbook w = new WritableWorkbookImpl(os, in, false, ws);
return w;
}
Creates a writable workbook as a copy of
the workbook passed in. Once created, the contents of the writable
workbook may be modified |
abstract public 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 |
abstract public 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 |
abstract public 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 |
abstract public int getNumberOfSheets()
Returns the number of sheets in this workbook |
abstract public String[] getRangeNames()
|
abstract public 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 |
abstract public 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 |
abstract public String[] getSheetNames()
|
abstract public Sheet[] getSheets()
Gets the sheets within this workbook. Use of this method for
large worksheets can cause performance problems. |
public static String getVersion() {
return VERSION;
}
Accessor for the software version |
public static Workbook getWorkbook(File file) throws BiffException, IOException {
return getWorkbook(file, new WorkbookSettings());
}
A factory method which takes in an excel file and reads in the contents. |
public static Workbook getWorkbook(InputStream is) throws BiffException, IOException {
return getWorkbook(is, new WorkbookSettings());
}
A factory method which takes in an excel file and reads in the contents. |
public static Workbook getWorkbook(File file,
WorkbookSettings ws) throws BiffException, IOException {
FileInputStream fis = new FileInputStream(file);
// Always close down the input stream, regardless of whether or not the
// file can be parsed. Thanks to Steve Hahn for this
File dataFile = null;
try
{
dataFile = new File(fis, ws);
}
catch (IOException e)
{
fis.close();
throw e;
}
catch (BiffException e)
{
fis.close();
throw e;
}
fis.close();
Workbook workbook = new WorkbookParser(dataFile, ws);
workbook.parse();
return workbook;
}
A factory method which takes in an excel file and reads in the contents. |
public static Workbook getWorkbook(InputStream is,
WorkbookSettings ws) throws BiffException, IOException {
File dataFile = new File(is, ws);
Workbook workbook = new WorkbookParser(dataFile, ws);
workbook.parse();
return workbook;
}
A factory method which takes in an excel file and reads in the contents. |
abstract public boolean isProtected()
Determines whether the sheet is protected |
abstract protected void parse() throws BiffException, PasswordException
Parses the excel file.
If the workbook is password protected a PasswordException is thrown
in case consumers of the API wish to handle this in a particular way |