net.sf.jxls.transformer
Class XLSTransformer

java.lang.Object
  extended by net.sf.jxls.transformer.XLSTransformer

public class XLSTransformer
extends java.lang.Object

This class uses excel template to generate excel file filled with required objects and collections.

Author:
Leonid Vysochyn, Vincent Dutat

Field Summary
protected static org.apache.commons.logging.Log log
           
 
Constructor Summary
XLSTransformer()
           
XLSTransformer(Configuration configuration)
           
 
Method Summary
 java.lang.String[] getColumnPropertyNamesToHide()
           
 short[] getColumnsToHide()
           
 Configuration getConfiguration()
           
 FormulaResolver getFormulaResolver()
           
protected  java.lang.String getSpreadsheetToReName(java.lang.String name)
           
 void groupCollection(java.lang.String collectionName)
          Set this collection to be grouped (outlined).
 boolean isJexlInnerCollectionsAccess()
           
protected  boolean isSpreadsheetToRemove(java.lang.String name)
           
protected  boolean isSpreadsheetToRename(java.lang.String name)
           
 void markAsFixedSizeCollection(java.lang.String collectionName)
          Mark a collection as static collection.
 void registerCellProcessor(CellProcessor cellProcessor)
          Registers CellProcessor object
 void registerPropertyPreprocessor(PropertyPreprocessor propPreprocessor)
          Registers Property Preprocessor that will be applied before main template transformation it is possible to have many Property Preprocessors
 void registerRowProcessor(RowProcessor rowProcessor)
          Registers RowProcessor object
 void setColumnPropertyNamesToHide(java.lang.String[] columnPropertyNamesToHide)
          Set the columns to hide in result XLS
 void setColumnsToHide(short[] columnsToHide)
          Sets the columns to hide in result XLS
 void setConfiguration(Configuration configuration)
           
 void setFormulaResolver(FormulaResolver formulaResolver)
          Sets FormulaResolver to be used in resolving formula
 void setJexlInnerCollectionsAccess(boolean jexlInnerCollectionsAccess)
           
 void setSpreadsheetsToRemove(java.lang.String[] names)
          Set spreadsheets with given names to be hidden
 void setSpreadsheetToRename(java.lang.String name, java.lang.String newName)
           
 org.apache.poi.ss.usermodel.Workbook transformMultipleSheetsList(java.io.InputStream is, java.util.List objects, java.util.List newSheetNames, java.lang.String beanName, java.util.Map beanParams, int startSheetNum)
          This method transforms given XLS input stream template into multiple sheets workbook creating separate Excel worksheet for every object in the list
 void transformWorkbook(org.apache.poi.ss.usermodel.Workbook hssfWorkbook, java.util.Map beanParams)
           
 org.apache.poi.ss.usermodel.Workbook transformXLS(java.io.InputStream is, java.util.List templateSheetNameList, java.util.List sheetNameList, java.util.List beanParamsList)
          Multiple sheet template multiple transform.
 org.apache.poi.ss.usermodel.Workbook transformXLS(java.io.InputStream is, java.util.Map beanParams)
          Creates Workbook instance based on .xls template from a given InputStream and a number of beans
 void transformXLS(java.lang.String srcFilePath, java.util.Map beanParams, java.lang.String destFilePath)
          Creates new .xls file at a given path using specified excel template file and a number of beans.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
Constructor Detail

XLSTransformer

public XLSTransformer()

XLSTransformer

public XLSTransformer(Configuration configuration)
Method Detail

registerPropertyPreprocessor

public void registerPropertyPreprocessor(PropertyPreprocessor propPreprocessor)
Registers Property Preprocessor that will be applied before main template transformation it is possible to have many Property Preprocessors

Parameters:
propPreprocessor - - PropertyPreprocessor interface implementation

registerRowProcessor

public void registerRowProcessor(RowProcessor rowProcessor)
Registers RowProcessor object

Parameters:
rowProcessor - RowProcessor to register

registerCellProcessor

public void registerCellProcessor(CellProcessor cellProcessor)
Registers CellProcessor object

Parameters:
cellProcessor - to register

markAsFixedSizeCollection

public void markAsFixedSizeCollection(java.lang.String collectionName)
Mark a collection as static collection. All static collection rows are presented in Excel template and will not be expanded

Parameters:
collectionName - - Collection name to mark as fixed size collection

getConfiguration

public Configuration getConfiguration()

setConfiguration

public void setConfiguration(Configuration configuration)

getFormulaResolver

public FormulaResolver getFormulaResolver()
Returns:
FormulaResolver used to resolve coded formulas

setFormulaResolver

public void setFormulaResolver(FormulaResolver formulaResolver)
Sets FormulaResolver to be used in resolving formula

Parameters:
formulaResolver - FormulaResolver implementation to set

isJexlInnerCollectionsAccess

public boolean isJexlInnerCollectionsAccess()

setJexlInnerCollectionsAccess

public void setJexlInnerCollectionsAccess(boolean jexlInnerCollectionsAccess)

groupCollection

public void groupCollection(java.lang.String collectionName)
Set this collection to be grouped (outlined).

Parameters:
collectionName - - Collection name to use for grouping

transformXLS

public void transformXLS(java.lang.String srcFilePath,
                         java.util.Map beanParams,
                         java.lang.String destFilePath)
                  throws ParsePropertyException,
                         java.io.IOException,
                         org.apache.poi.openxml4j.exceptions.InvalidFormatException
Creates new .xls file at a given path using specified excel template file and a number of beans. This method invokes transformXLS(InputStream is, Map beanParams) passing input stream from a template file and then writing resulted Workbook into required output file.

Parameters:
srcFilePath - Path to source .xls template file
beanParams - Map of beans to be applied to .xls template file with keys corresponding to bean aliases in template
destFilePath - Path to result .xls file
Throws:
ParsePropertyException - if there were any problems in evaluating specified property value from a bean
java.io.IOException - if there were any access or input/output problems with source or destination file
org.apache.poi.openxml4j.exceptions.InvalidFormatException

transformXLS

public org.apache.poi.ss.usermodel.Workbook transformXLS(java.io.InputStream is,
                                                         java.util.Map beanParams)
                                                  throws ParsePropertyException,
                                                         org.apache.poi.openxml4j.exceptions.InvalidFormatException
Creates Workbook instance based on .xls template from a given InputStream and a number of beans

Parameters:
is - xls InputStream with required
beanParams - Beans in a map under keys used in .xls template to access to the beans
Returns:
new Workbook generated by inserting beans into corresponding excel template
Throws:
ParsePropertyException - if there were any problems in evaluating specified property value from a bean
org.apache.poi.openxml4j.exceptions.InvalidFormatException

transformWorkbook

public void transformWorkbook(org.apache.poi.ss.usermodel.Workbook hssfWorkbook,
                              java.util.Map beanParams)

transformMultipleSheetsList

public org.apache.poi.ss.usermodel.Workbook transformMultipleSheetsList(java.io.InputStream is,
                                                                        java.util.List objects,
                                                                        java.util.List newSheetNames,
                                                                        java.lang.String beanName,
                                                                        java.util.Map beanParams,
                                                                        int startSheetNum)
                                                                 throws ParsePropertyException,
                                                                        org.apache.poi.openxml4j.exceptions.InvalidFormatException
This method transforms given XLS input stream template into multiple sheets workbook creating separate Excel worksheet for every object in the list

Parameters:
is - - InputStream for source XLS template file
objects - - List of beans where each list item should be exported into a separated worksheet
newSheetNames - - Sheet names to be used for newly created worksheets
beanName - - Bean name to be used for a list item when processing sheet
beanParams - - Common bean map containing all other objects to be used in the workbook
startSheetNum - - Worksheet number (zero based) of the worksheet that needs to be used to create multiple worksheets
Returns:
new Workbook object containing the result of transformation
Throws:
ParsePropertyException - - ParsePropertyException is thrown when some property can't be parsed
org.apache.poi.openxml4j.exceptions.InvalidFormatException

transformXLS

public org.apache.poi.ss.usermodel.Workbook transformXLS(java.io.InputStream is,
                                                         java.util.List templateSheetNameList,
                                                         java.util.List sheetNameList,
                                                         java.util.List beanParamsList)
                                                  throws ParsePropertyException,
                                                         org.apache.poi.openxml4j.exceptions.InvalidFormatException
Multiple sheet template multiple transform. It can be used to generate a workbook with N (N=N1+N2+...+Nn) sheets based on : - N1 transformations of the sheet template T1 - N2 transformations of the sheet template T2 ... - Nn transformations of the sheet template Tn

Parameters:
is - the InputStream of the workbook template containing the n template sheets
templateSheetNameList - the ordered list of the template sheet name used in the transformation.
sheetNameList - the ordered list of the resulting sheet name after transformation
beanParamsList - the ordered list of beanParams used in the transformation
Returns:
- Workbook representing transformation result
Throws:
ParsePropertyException - in case property parsing failure
org.apache.poi.openxml4j.exceptions.InvalidFormatException

getColumnsToHide

public short[] getColumnsToHide()
Returns:
The column numbers to hide in result XLS

setColumnsToHide

public void setColumnsToHide(short[] columnsToHide)
Sets the columns to hide in result XLS

Parameters:
columnsToHide - - Column numbers to hide

getColumnPropertyNamesToHide

public java.lang.String[] getColumnPropertyNamesToHide()
Returns:
The property names for which all columns containing them should be hidden

setColumnPropertyNamesToHide

public void setColumnPropertyNamesToHide(java.lang.String[] columnPropertyNamesToHide)
Set the columns to hide in result XLS

Parameters:
columnPropertyNamesToHide - - The names of bean properties for which all columns containing this properties should be hidden

setSpreadsheetsToRemove

public void setSpreadsheetsToRemove(java.lang.String[] names)
Set spreadsheets with given names to be hidden

Parameters:
names - - Names of the worksheets to hide

setSpreadsheetToRename

public void setSpreadsheetToRename(java.lang.String name,
                                   java.lang.String newName)

isSpreadsheetToRemove

protected boolean isSpreadsheetToRemove(java.lang.String name)

isSpreadsheetToRename

protected boolean isSpreadsheetToRename(java.lang.String name)

getSpreadsheetToReName

protected java.lang.String getSpreadsheetToReName(java.lang.String name)


Copyright © 2005-2013 jXLS Team. All Rights Reserved.