|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjet.report.xls.Workbook
public class Workbook
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.
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 |
|---|
public Workbook(java.lang.String encoding,
int buffersize,
java.lang.String path)
Workbook object with these 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
public Workbook(java.lang.String encoding,
java.lang.String path)
Workbook object with these parameters. Note the bufferize is 4.
encoding - the encode value, and it can be null. We don't use it now.path - the temporary path to create the temporary files.Workbook(String, int, String)| Method Detail |
|---|
public GlobalWorksheet getGlobalWorksheet()
public void output(java.io.OutputStream out)
throws java.io.IOException
out.
out - the output stream
java.io.IOException - some exception will be produced when writing the contents to the stream out
public void free()
throws java.io.IOException
Worksheet.
java.io.IOException - the exception produced
public void add(Worksheet worksheet)
throws java.io.IOException
Worksheet object to the Workbook.
worksheet - the Worksheet object
java.io.IOException - the exception produced
public Worksheet getWorksheet(int index)
throws java.io.IOException
Worksheet object according to the sheet index.
index - the sheet index, which is based on zero. That is, the first added sheet index is 0, the second is 1.
java.io.IOException - the exception produced
public Worksheet getWorksheet(java.lang.String sheetName)
throws java.io.IOException
Worksheet according to the sheet's name.
sheetName - the sheet's name
Worksheet according to the sheet name
java.io.IOException - the exception produced
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||