|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jett.transform.ExcelTransformer
public class ExcelTransformer
The ExcelTransformer class represents the main JETT API.
An ExcelTransformer knows how to transform Excel template
workbooks into fully populated Excel workbooks, using caller-supplied data
in the form of beans. This class is the entry point API for JETT.
There are four main methods that accomplish all of the work, all with the overloaded name "transform":
public void transform(String inFilename, String outFilename, Map beans)
throws IOException, InvalidFormatException
public Workbook transform(InputStream is, Map<String, Object> beans)
throws IOException, InvalidFormatException
public void transform(String inFilename, String outFilename, List templateSheetNamesList,
List newSheetNamesList, List
public Workbook transform(InputStream is, List<String> templateSheetNamesList, List<String> newSheetNamesList,
List<Map<tring, Object>> beansList) throws IOException, InvalidFormatException
The first method reads the template spreadsheet from the input filename, applies the bean values across all sheets, and writes the transformed spreadsheet to the output filename.
The second method reads the template spreadsheet from the given input
stream (usually a file), applies the bean values across all sheets, and
returs a Workbook object representing the transformed
spreadsheet, which can be written to a file if desired. The first method
calls the second method to do its work.
The third method reads the template spreadsheet from the input filename, applies specific bean values to specific sheets, and writes the transformed spreadsheet to the output filename.
The fourth method reads the template spreadsheet from the given input
stream (usually a file), applies specific bean values to specific sheets,
and returs a Workbook object representing the transformed
spreadsheet, which can be written to a file if desired. The third method
calls the fourth method to do its work.
The ExcelTransformer's settings can be changed with the
other public methods of this class, including recognizing custom tag
libraries, adding CellListeners, using fixed size collections,
turning off implicit collections processing, passing silent and
lenient flags through to the underlying JEXL Engine,
passing a cache size to the internal JEXL Engine, passing namespace objects
to register custom functions in the JEXL Engine, and passing CSS files/text
to be recognized by the StyleTag later.
| Constructor Summary | |
|---|---|
ExcelTransformer()
Construct an ExcelTransformer. |
|
| Method Summary | |
|---|---|
void |
addCellListener(CellListener listener)
Registers the given CellListener. |
void |
addCssFile(java.lang.String filename)
Register a file containing CSS-like style definitions. |
void |
addCssText(java.lang.String cssText)
Register one or more style definitions, without having to read them from a file. |
void |
addFixedSizeCollectionName(java.lang.String collName)
This particular named Collection has a known size and does
not need to have other Cells shifted out of the way for its
contents; space is already allocated. |
void |
registerFuncs(java.lang.String namespace,
java.lang.Object funcsObject)
Registers an object under the given namespace in the internal JEXL Engine. |
void |
registerTagLibrary(java.lang.String namespace,
TagLibrary library)
Registers the given TagLibrary so that this
ExcelTransformer can recognize tags from the given
namespace. |
void |
setCache(int size)
Creates and uses a JEXL Expression cache of the given size. |
void |
setLenient(boolean lenient)
Sets whether the JEXL "lenient" flag is set. |
void |
setSilent(boolean silent)
Sets whether the JEXL "silent" flag is set. |
org.apache.poi.ss.usermodel.Workbook |
transform(java.io.InputStream is,
java.util.List<java.lang.String> templateSheetNamesList,
java.util.List<java.lang.String> newSheetNamesList,
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> beansList)
Transforms the template Excel spreadsheet represented by the given InputStream. |
org.apache.poi.ss.usermodel.Workbook |
transform(java.io.InputStream is,
java.util.Map<java.lang.String,java.lang.Object> beans)
Transforms the template Excel spreadsheet represented by the given InputStream. |
void |
transform(java.lang.String inFilename,
java.lang.String outFilename,
java.util.List<java.lang.String> templateSheetNamesList,
java.util.List<java.lang.String> newSheetNamesList,
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> beansList)
Transforms the template Excel spreadsheet represented by the given input filename. |
void |
transform(java.lang.String inFilename,
java.lang.String outFilename,
java.util.Map<java.lang.String,java.lang.Object> beans)
Transforms the template Excel spreadsheet represented by the given input filename. |
void |
turnOffImplicitCollectionProcessing(java.lang.String collName)
The caller is stating that it will be explicitly accessing item(s) in the named Collection, so implicit collections processing should
NOT be performed on this collection. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ExcelTransformer()
ExcelTransformer.
| Method Detail |
|---|
public void registerTagLibrary(java.lang.String namespace,
TagLibrary library)
TagLibrary so that this
ExcelTransformer can recognize tags from the given
namespace.
namespace - The namespace associated with the tag library.library - The TagLibrary.
java.lang.IllegalArgumentException - If the namespace has already been
registered.public void addCellListener(CellListener listener)
CellListener.
listener - A CellListener.public void addFixedSizeCollectionName(java.lang.String collName)
Collection has a known size and does
not need to have other Cells shifted out of the way for its
contents; space is already allocated.
collName - The name of the Collection that doesn't need
other Cells shifted out of the way for its contents.public void turnOffImplicitCollectionProcessing(java.lang.String collName)
Collection, so implicit collections processing should
NOT be performed on this collection. Implicit collections processing
will still occur on Collections known by other names.
collName - The name of the Collection on which NOT to
perform implicit collections processing.public void setLenient(boolean lenient)
lenient - Whether the JEXL "lenient" flag is set.public void setSilent(boolean silent)
false.
silent - Whether the JEXL "silent" flag is set.public void setCache(int size)
size - The size of the JEXL Expression cache.
public void registerFuncs(java.lang.String namespace,
java.lang.Object funcsObject)
Class object.
namespace - The namespace used to access the functions object.funcsObject - An object (or a Class) containing the
methods to expose as JEXL Engine functions.
java.lang.IllegalArgumentException - If the namespace has already been
registered.public void addCssText(java.lang.String cssText)
Register one or more style definitions, without having to read them from a file. Style definitions are of the format (whitespace is ignored):
[.styleName { [propertyName: value [; propertyName: value]* }]*
These style names are recognized by the "class" attribute of the "style" tag.
cssText - A string containing one or more style definitions.
StyleParseException - If there is a problem
parsing the style definition text.StyleTag
public void addCssFile(java.lang.String filename)
throws java.io.IOException
Register a file containing CSS-like style definitions. Style definitions are of the format (whitespace is ignored):
[.styleName { [propertyName: value [; propertyName: value]* }]*
These style names are recognized by the "class" attribute of the "style" tag.
filename - The name of a file containing CSS-like style definitions.
java.io.IOException - If there is a problem reading the file.
StyleParseException - If there is a problem
parsing the style definition text.StyleTag
public void transform(java.lang.String inFilename,
java.lang.String outFilename,
java.util.Map<java.lang.String,java.lang.Object> beans)
throws java.io.IOException,
org.apache.poi.openxml4j.exceptions.InvalidFormatException
Map of beans to all sheets.
Writes the resultant Excel spreadsheet to the given output filename.
inFilename - The template spreadsheet filename.outFilename - The resultant spreadsheet filename.beans - The Map of bean names to bean objects.
java.io.IOException - If there is a problem reading or writing any Excel
spreadsheet.
org.apache.poi.openxml4j.exceptions.InvalidFormatException - If there is a problem creating a
Workbook object.
public org.apache.poi.ss.usermodel.Workbook transform(java.io.InputStream is,
java.util.Map<java.lang.String,java.lang.Object> beans)
throws java.io.IOException,
org.apache.poi.openxml4j.exceptions.InvalidFormatException
InputStream. Applies the given Map of beans
to all sheets.
is - The InputStream from the template spreadsheet.beans - The Map of bean names to bean objects.
Workbook object capable of being written to an
OutputStream.
java.io.IOException - If there is a problem reading the template Excel
spreadsheet.
org.apache.poi.openxml4j.exceptions.InvalidFormatException - If there is a problem creating a
Workbook object.
public void transform(java.lang.String inFilename,
java.lang.String outFilename,
java.util.List<java.lang.String> templateSheetNamesList,
java.util.List<java.lang.String> newSheetNamesList,
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> beansList)
throws java.io.IOException,
org.apache.poi.openxml4j.exceptions.InvalidFormatException
Map
of bean names to bean values exposed to it. Writes the resultant Excel
spreadsheet to the given output filename.
inFilename - The template spreadsheet filename.outFilename - The resultant spreadsheet filename.templateSheetNamesList - A List of template sheet
names, with duplicates indicating to clone sheets.newSheetNamesList - A List of resulting sheet names
corresponding to the template sheet names list.beansList - A List of Maps representing
the beans map exposed to each resulting sheet.
java.io.IOException - If there is a problem reading or writing any Excel
spreadsheet.
org.apache.poi.openxml4j.exceptions.InvalidFormatException - If there is a problem creating a
Workbook object.
public org.apache.poi.ss.usermodel.Workbook transform(java.io.InputStream is,
java.util.List<java.lang.String> templateSheetNamesList,
java.util.List<java.lang.String> newSheetNamesList,
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> beansList)
throws java.io.IOException,
org.apache.poi.openxml4j.exceptions.InvalidFormatException
InputStream. If a sheet name is represented n
times in the list of template sheet names, then it will cloned to make
n total copies and the clones will receive the corresponding
sheet name from the list of sheet names. Each resulting sheet has a
corresponding Map of bean names to bean values exposed to
it.
is - The InputStream from the template spreadsheet.templateSheetNamesList - A List of template sheet
names, with duplicates indicating to clone sheets.newSheetNamesList - A List of resulting sheet names
corresponding to the template sheet names list.beansList - A List of Maps representing
the beans map exposed to each resulting sheet.
Workbook object capable of being written to an
OutputStream.
java.io.IOException - If there is a problem reading the template Excel
spreadsheet.
org.apache.poi.openxml4j.exceptions.InvalidFormatException - If there is a problem creating a
Workbook object.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||