jet.report.xls
Class Workbook

java.lang.Object
  extended by jet.report.xls.Workbook
All Implemented Interfaces:
jet.report.xls.DataConstants

public class Workbook
extends java.lang.Object
implements jet.report.xls.DataConstants

It specifies an XLS format excel file.

You can create an excel file like as:

 String encode = null;//the encode can be null, we don't use it now.
 String tempPath = "c:\\temp";//the tempPath can't be null and it should be an existing folder.
 Workbook book = null;
 
 try
 {
 
        book = new Workbook(encode, tempPath);
        GlobalWorksheet gws = book.getGlobalWorksheet();//gets the GlobalWorksheet object from the book object, which will be used when adding contents to sheet.
        Worksheet sheet = new Worksheet( encode );//creates a sheet object and then you can add some contents to the sheet object.
        book.add( sheet );
        String name = "c:\\out\\out.xls";//the path in the name should be valid
        OutputStream outFile = new FileOutputStream( name );
        book.output( outFile );
        outFile.close();
 
 }
 finally
 {
        if( book != null )
        {
                book.free();
        }
 }
 

About how to add contents to sheet, see the Worksheet.

See Also:
Worksheet

Field Summary
 
Fields inherited from interface jet.report.xls.DataConstants
BIG_BLOCK_SIZE, BYTE, DIRECTORY_TYPE, DOCUMENT_TYPE, DOUBLE, FLOAT, INT, LONG, MAX_LENGTH, MAX_RECORD_SIZE, MIN_DOC_SIZE, PROPERTY_SIZE, PROPERTY_TYPE_OFFSET, ROOT_TYPE, SHORT, SMALL_BLOCK_SIZE, UNUSED_BLOCK
 
Constructor Summary
Workbook(java.lang.String encoding, int buffersize, java.lang.String path)
          Creates a Workbook object with these parameters:
Workbook(java.lang.String encoding, java.lang.String path)
          Creates a Workbook object with these parameters.
 
Method Summary
 void add(Worksheet worksheet)
          Adds a Worksheet object to the Workbook.
 void free()
          Frees the temporary files created when writing the Worksheet.
 GlobalWorksheet getGlobalWorksheet()
          Gets the GlobalWorksheet of the Workbook.
 Worksheet getWorksheet(int index)
          Gets a Worksheet object according to the sheet index.
 Worksheet getWorksheet(java.lang.String sheetName)
          Gets the Worksheet according to the sheet's name.
 void output(java.io.OutputStream out)
          Writes the excel contents to the stream out.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Workbook

public Workbook(java.lang.String encoding,
                int buffersize,
                java.lang.String path)
Creates a Workbook object with these parameters:

Parameters:
encoding - the encode value, and it can be null. We don't use it now.
buffersize - Specifies the cache Worksheet size in the memory. That is, if there are more Worksheet to be added to this Workbook and they exceed the bufferzie, some Worksheet will be written to temporary file which is created on the path given with the path parameter.
path - the temporary path to create the temporary files

Workbook

public Workbook(java.lang.String encoding,
                java.lang.String path)
Creates a Workbook object with these parameters. Note the bufferize is 4.

Parameters:
encoding - the encode value, and it can be null. We don't use it now.
path - the temporary path to create the temporary files.
See Also:
Workbook(String, int, String)
Method Detail

getGlobalWorksheet

public GlobalWorksheet getGlobalWorksheet()
Gets the GlobalWorksheet of the Workbook.


output

public void output(java.io.OutputStream out)
            throws java.io.IOException
Writes the excel contents to the stream out.

Parameters:
out - the output stream
Throws:
java.io.IOException - some exception will be produced when writing the contents to the stream out

free

public void free()
          throws java.io.IOException
Frees the temporary files created when writing the Worksheet.

Throws:
java.io.IOException - the exception produced

add

public void add(Worksheet worksheet)
         throws java.io.IOException
Adds a Worksheet object to the Workbook.

Parameters:
worksheet - the Worksheet object
Throws:
java.io.IOException - the exception produced

getWorksheet

public Worksheet getWorksheet(int index)
                       throws java.io.IOException
Gets a Worksheet object according to the sheet index.

Parameters:
index - the sheet index, which is based on zero. That is, the first added sheet index is 0, the second is 1.
Returns:
null if the index is equal to or higher than the added sheet number
Throws:
java.io.IOException - the exception produced

getWorksheet

public Worksheet getWorksheet(java.lang.String sheetName)
                       throws java.io.IOException
Gets the Worksheet according to the sheet's name.

Parameters:
sheetName - the sheet's name
Returns:
null if you can not find the Worksheet according to the sheet name
Throws:
java.io.IOException - the exception produced