|
Copyright © 2008-2011 Ralph Schuster. All Rights Reserved. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcsv.impl.AbstractTableWriter
csv.impl.AbstractStreamTableWriter
csv.impl.ExcelWriter
public class ExcelWriter
Provides ability to write Excel files.
The Excel will be written with a call to close() only!
Please notice that this implementation does not support writing formulas into
cells, yet.
Example:
java.io.File f = new java.io.File("excel-test.xls");
ExcelWriter out = new ExcelWriter(f);
out.printRow(new Object[] { "0:0", new Integer(3), new Date() });
out.printRow(new Object[] { "1:0", new Double(), "another String value" });
out.close();
close()| Constructor Summary | |
|---|---|
ExcelWriter()
Default constructor. |
|
ExcelWriter(java.io.File file)
Constructor for writing into a file. |
|
ExcelWriter(java.io.OutputStream out)
Constructor with defined output stream. |
|
ExcelWriter(java.lang.String file)
Constructor for writing into a file. |
|
ExcelWriter(org.apache.poi.ss.usermodel.Workbook workbook)
Constructor with existing workbook. |
|
ExcelWriter(org.apache.poi.ss.usermodel.Workbook workbook,
java.io.File file)
Constructor with existing workbook that needs to be written to a file. |
|
ExcelWriter(org.apache.poi.ss.usermodel.Workbook workbook,
java.io.OutputStream out)
Constructor with existing workbook and defined output stream. |
|
ExcelWriter(org.apache.poi.ss.usermodel.Workbook workbook,
java.lang.String file)
Constructor with existing workbook that needs to be written to a file. |
|
| Method Summary | |
|---|---|
void |
close()
Closes the writer and writes the Excel to the underlying stream. |
org.apache.poi.ss.usermodel.Sheet |
createSheet()
Creates a new sheet for the workbook. |
org.apache.poi.ss.usermodel.Sheet |
createSheet(int index)
Creates a new sheet for the workbook at specified index. |
org.apache.poi.ss.usermodel.Sheet |
createSheet(int index,
java.lang.String name)
Creates a new sheet for the workbook at specified index. |
ExcelFormatter |
getFormatter()
Returns the formatter set for this ExcelWriter. |
org.apache.poi.ss.usermodel.Cell |
getOrCreateCell(int row,
int column)
Returns an existing cell or creates one. |
org.apache.poi.ss.usermodel.Cell |
getOrCreateCell(org.apache.poi.ss.usermodel.Row row,
int column)
Returns an existing cell or creates one. |
org.apache.poi.ss.usermodel.Row |
getOrCreateRow(int row)
Returns an existing row or creates one. |
org.apache.poi.ss.usermodel.Sheet |
getSheet()
Returns the current sheet or creates a fresh one. |
org.apache.poi.ss.usermodel.Workbook |
getWorkbook()
Returns the workbook or creates a fresh one. |
protected void |
notifyExcelListeners(org.apache.poi.ss.usermodel.Row row)
Notifies all Excel Listeners about the new row. |
void |
printComment(java.lang.String comment,
int row,
int column)
Prints a comment into the output stream. |
void |
printRow(java.lang.Object[] columns)
Prints the values to the Excel file. |
void |
printRow(java.lang.Object[] columns,
int rowNum)
Prints the values to the Excel file at the given row. |
void |
registerExcelListener(ExcelListener l)
Registers an Excel Listener. |
org.apache.poi.ss.usermodel.Sheet |
selectSheet(int index)
This method selects the sheet at given index. |
void |
selectSheet(org.apache.poi.ss.usermodel.Sheet sheet)
This method selects the given sheet. |
void |
setFormatter(ExcelFormatter formatter)
Sets the formatter for this ExcelWriter. |
protected void |
setStyle(org.apache.poi.ss.usermodel.Cell cell,
java.lang.Object value)
Sets the style of a cell. |
void |
setValue(org.apache.poi.ss.usermodel.Cell cell,
java.lang.Object value)
Sets the value at the specified cell. |
void |
setValue(int row,
int column,
java.lang.Object value)
Sets the value at the specified cell. |
void |
setValue(org.apache.poi.ss.usermodel.Row row,
int column,
java.lang.Object value)
Sets the value at the specified cell. |
void |
unregisterExcelListener(ExcelListener l)
Unregisters an ExcelListener. |
| Methods inherited from class csv.impl.AbstractStreamTableWriter |
|---|
getOutputStream, getWriter, setOutputStream |
| Methods inherited from class csv.impl.AbstractTableWriter |
|---|
convert, convert, getRowCount, getTypeConversionHandler, incrementRowCount, init, printComment, registerTypeConversionHandler, unregisterTypeConversionHandler |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ExcelWriter()
AbstractStreamTableWriter.setOutputStream(OutputStream)public ExcelWriter(org.apache.poi.ss.usermodel.Workbook workbook)
workbook - the workbook to be usedAbstractStreamTableWriter.setOutputStream(OutputStream)public ExcelWriter(java.io.OutputStream out)
out - output stream to be used.
public ExcelWriter(org.apache.poi.ss.usermodel.Workbook workbook,
java.io.OutputStream out)
workbook - the workbook to be usedout - output stream to be used
public ExcelWriter(java.io.File file)
throws java.io.IOException
file - output file to be used
java.io.IOException - when the file cannot be written to
public ExcelWriter(org.apache.poi.ss.usermodel.Workbook workbook,
java.io.File file)
throws java.io.IOException
workbook - the workbook to be usedfile - output file to be used
java.io.IOException - when the file cannot be written to
public ExcelWriter(java.lang.String file)
throws java.io.IOException
file - output file to be used
java.io.IOException - when the file cannot be written to
public ExcelWriter(org.apache.poi.ss.usermodel.Workbook workbook,
java.lang.String file)
throws java.io.IOException
workbook - the workbook to be usedfile - output file to be used
java.io.IOException - when the file cannot be written to| Method Detail |
|---|
public void printRow(java.lang.Object[] columns)
throws java.io.IOException
printRow(Object[], int)
columns - values to be written to the Excel sheet
java.io.IOException - when an exception occursTableWriter.printRow(java.lang.Object[])
public void printRow(java.lang.Object[] columns,
int rowNum)
throws java.io.IOException
columns - values to be written to the Excel sheetrowNum - index of row to be written
java.io.IOExceptionprintRow(Object[])
public void printComment(java.lang.String comment,
int row,
int column)
throws java.io.IOException
printComment in interface TableWriterprintComment in class AbstractTableWritercomment - the comment to writerow - index of row for commentcolumn - index of column for comment
java.io.IOException - when an exception occurs
public org.apache.poi.ss.usermodel.Cell getOrCreateCell(int row,
int column)
row - row indexcolumn - column index
public org.apache.poi.ss.usermodel.Cell getOrCreateCell(org.apache.poi.ss.usermodel.Row row,
int column)
row - row objectcolumn - column index
public org.apache.poi.ss.usermodel.Row getOrCreateRow(int row)
ExcelListeners about a new row.
row - row index
public void setValue(int row,
int column,
java.lang.Object value)
row - row indexcolumn - column indexvalue - value to be setsetValue(Cell, Object)
public void setValue(org.apache.poi.ss.usermodel.Row row,
int column,
java.lang.Object value)
row - row objectcolumn - column indexvalue - value to be setsetValue(Cell, Object)
public void setValue(org.apache.poi.ss.usermodel.Cell cell,
java.lang.Object value)
ExcelFormatter to set the correct style
on this cell.
cell - cell objectvalue - value to be setpublic org.apache.poi.ss.usermodel.Workbook getWorkbook()
public org.apache.poi.ss.usermodel.Sheet getSheet()
public void selectSheet(org.apache.poi.ss.usermodel.Sheet sheet)
printRow(Object[])).
sheet - sheet to be selectedpublic org.apache.poi.ss.usermodel.Sheet selectSheet(int index)
printRow(Object[])).
index - sheet index
public org.apache.poi.ss.usermodel.Sheet createSheet()
public org.apache.poi.ss.usermodel.Sheet createSheet(int index)
index - of sheet (-1 adds the sheet at the end of all sheet)
public org.apache.poi.ss.usermodel.Sheet createSheet(int index,
java.lang.String name)
name - name of new sheetindex - of sheet (-1 adds the sheet at the end of all sheet)
public void close()
close in interface TableWriterclose in class AbstractStreamTableWriterAbstractStreamTableWriter.close()public void registerExcelListener(ExcelListener l)
l - the listenerpublic void unregisterExcelListener(ExcelListener l)
l - the listenerprotected void notifyExcelListeners(org.apache.poi.ss.usermodel.Row row)
row - the row that was createdpublic ExcelFormatter getFormatter()
public void setFormatter(ExcelFormatter formatter)
formatter - the formatter to setExcelFormatter,
setValue(Cell, Object),
setStyle(Cell, Object)
protected void setStyle(org.apache.poi.ss.usermodel.Cell cell,
java.lang.Object value)
ExcelFormatter.setStyle(ExcelWriter, Cell, Object).
cell - cell to be formattedvalue - value that was setsetFormatter(ExcelFormatter)
|
Copyright © 2008-2011 Ralph Schuster. All Rights Reserved. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||