Package org.jxls.builder
Class JxlsTemplateFillerBuilder<SELF extends JxlsTemplateFillerBuilder<SELF>>
java.lang.Object
org.jxls.builder.JxlsTemplateFillerBuilder<SELF>
This builder is the starting point for creating reports using Jxls.
After setting the options using the with... methods, call build(). This results in a TemplateFiller with a fill() method.
See website for detailed explanations of all options.
You must call withTransformerFactory() and withTemplate().
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanstatic final Stringstatic final Stringprotected Stringprotected Stringprotected booleanprotected booleanprotected KeepTemplateSheetold names: deleteTemplateSheet, hideTemplateSheetprotected JxlsLoggerprotected final List<NeedsPublicContext>protected final List<PreWriteAction>protected booleanold name: evaluateFormulasprotected booleanold name: fullFormulaRecalculationOnOpeningprotected RunVarAccessprotected InputStreamprotected booleanold name: formulaProcessingRequired -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()byte[]buildAndFill(Map<String, Object> data) Builds template filler, creates Excel report with given data and returns Excel file as byte array.voidbuildAndFill(Map<String, Object> data, File outputFile) Builds template filler, creates Excel report with given data and saves it to given output file.voidbuildAndFill(Map<String, Object> data, JxlsOutput output) Builds template filler, creates Excel report with given data and saves it to output.Creates internal used options object for template fillerneedsPublicContext(NeedsPublicContext needsPublicContext) If you are adding an object to the data map which needsPublicContextaccess, implement the NeedsPublicContext interface and call this method.static JxlsTemplateFillerBuilder<?>withAreaBuilder(AreaBuilder areaBuilder) See websitewithClearTemplateCells(boolean clearTemplateCells) withCommand(String name, Class<? extends Command> commandClass) Adds a command.withExpressionEvaluatorFactory(ExpressionEvaluatorFactory expressionEvaluatorFactory) Defines a factory class with which ExpressionEvaluator classes are created during report creation.withExpressionNotation(String begin, String end) Expressions in Excel cells are inside${and}.Sets FastFormulaProcessor which is 10 times faster but can handle only simple templates.withFormulaProcessor(FormulaProcessor formulaProcessor) withIgnoreColumnProps(boolean ignoreColumnProps) See websitewithIgnoreRowProps(boolean ignoreRowProps) See websitewithKeepTemplateSheet(KeepTemplateSheet keepTemplateSheet) This is for the multisheet feature.withLogger(JxlsLogger logger) Defines which class should be used for logging and throwing exceptions.withPreWriteAction(PreWriteAction preWriteAction) withRecalculateFormulasBeforeSaving(boolean recalculateFormulasBeforeSaving) Call this method with argument false if you don't need an extra recalculation of all formula results before saving the Excel file.withRecalculateFormulasOnOpening(boolean recalculateFormulasOnOpening) Call this method with argument true if you all formula results should be recalculated while opening the report file using Microsoft Excel.withRunVarAccess(RunVarAccess runVarAccess) Change the behavior for accessing run vars.withStreaming(JxlsStreaming streaming) Use streaming if you have large sheets.withTemplate(File templateFile) withTemplate(InputStream templateInputStream) withTemplate(String templateFileName) withTemplate(URL templateURL) withTransformerFactory(JxlsTransformerFactory transformerFactory) See websitewithUpdateCellDataArea(boolean updateCellDataArea) Cell reference tracking
-
Field Details
-
DEFAULT_EXPRESSION_BEGIN
- See Also:
-
DEFAULT_EXPRESSION_END
- See Also:
-
expressionNotationBegin
-
expressionNotationEnd
-
logger
-
updateCellDataArea
protected boolean updateCellDataAreaold name: formulaProcessingRequired -
ignoreColumnProps
protected boolean ignoreColumnProps -
ignoreRowProps
protected boolean ignoreRowProps -
recalculateFormulasBeforeSaving
protected boolean recalculateFormulasBeforeSavingold name: evaluateFormulas -
recalculateFormulasOnOpening
protected boolean recalculateFormulasOnOpeningold name: fullFormulaRecalculationOnOpening -
keepTemplateSheet
old names: deleteTemplateSheet, hideTemplateSheet -
commands
-
clearTemplateCells
protected boolean clearTemplateCells -
template
-
needsContextList
-
preWriteActions
-
runVarAccess
-
-
Constructor Details
-
JxlsTemplateFillerBuilder
public JxlsTemplateFillerBuilder()
-
-
Method Details
-
newInstance
- Returns:
- new builder instance
-
build
- Returns:
- JxlsTemplateFiller with all options and the template
-
buildAndFill
Builds template filler, creates Excel report with given data and saves it to output.- Parameters:
data- not nulloutput- not null
-
buildAndFill
Builds template filler, creates Excel report with given data and saves it to given output file.- Parameters:
data- -outputFile- -
-
buildAndFill
Builds template filler, creates Excel report with given data and returns Excel file as byte array.- Parameters:
data- -- Returns:
- byte[]
-
getOptions
Creates internal used options object for template filler- Returns:
- JxlsOptions
-
withExpressionEvaluatorFactory
Defines a factory class with which ExpressionEvaluator classes are created during report creation. It is recommended to usenew ExpressionEvaluatorFactoryJexlImpl(false, true, JxlsJexlPermissions.RESTRICTED)in production use.- Parameters:
expressionEvaluatorFactory- not null. Default is ExpressionEvaluatorFactoryJexlImpl with settings: silent=true, strict=false, JxlsJexlPermissions.UNRESTRICTED.- Returns:
- this
-
getExpressionEvaluatorFactory
-
withExpressionNotation
Expressions in Excel cells are inside${and}. Use this method to change those Strings.- Parameters:
begin- You can use null for the default value "${".end- You can use null for the default value "}".- Returns:
- this
-
withLogger
Defines which class should be used for logging and throwing exceptions.- Parameters:
logger- not null- Returns:
- this
-
withFormulaProcessor
- Parameters:
formulaProcessor- null for disabling formula processing, default: StandardFormulaProcessor- Returns:
- this
-
getFormulaProcessor
-
withFastFormulaProcessor
Sets FastFormulaProcessor which is 10 times faster but can handle only simple templates.- Returns:
- this
-
withUpdateCellDataArea
Cell reference tracking- Parameters:
updateCellDataArea- false to turn this feature off- Returns:
- this
-
withIgnoreColumnProps
See website- Parameters:
ignoreColumnProps- default is false- Returns:
- this
-
withIgnoreRowProps
See website- Parameters:
ignoreRowProps- default is false- Returns:
- this
-
withRecalculateFormulasBeforeSaving
Call this method with argument false if you don't need an extra recalculation of all formula results before saving the Excel file.- Parameters:
recalculateFormulasBeforeSaving- default is true- Returns:
- this
-
withRecalculateFormulasOnOpening
Call this method with argument true if you all formula results should be recalculated while opening the report file using Microsoft Excel.- Parameters:
recalculateFormulasOnOpening- default is false- Returns:
- this
-
withKeepTemplateSheet
This is for the multisheet feature. The template sheet is deleted by default. Call this method with argument KEEP if you want to keep the template sheet. Call this method with argument HIDE if you just want to hide the template sheet.- Parameters:
keepTemplateSheet- default is DELETE, null will be ignored.- Returns:
- this
-
withAreaBuilder
See website- Parameters:
areaBuilder- not null. Default is XlsCommentAreaBuilder.- Returns:
- this
-
getAreaBuilder
-
withCommand
Adds a command.- Parameters:
name- command name without "jx": prefixcommandClass- -- Returns:
- this
-
withClearTemplateCells
- Parameters:
clearTemplateCells- true (default): cells where the expression can not be evaluated will be cleared, false: cells where the expression can not be evaluated will keep the expression.- Returns:
- this
-
withTransformerFactory
See website- Parameters:
transformerFactory- -- Returns:
- this
-
getTransformerFactory
-
withStreaming
Use streaming if you have large sheets. However, not all features can be used. See website.- Parameters:
streaming- Default is STREAMING_OFF for no streaming. STREAMING_ON: streaming for all sheets. AUTO_DETECT: streaming for sheets which have the exact textsheetStreaming="true"in its jx:area command.- Returns:
- this
-
getStreaming
-
needsPublicContext
If you are adding an object to the data map which needsPublicContextaccess, implement the NeedsPublicContext interface and call this method.- Parameters:
needsPublicContext- your class which implements NeedsPublicContext for getting the PublicContext instance during report creation- Returns:
- this
-
withPreWriteAction
- Parameters:
preWriteAction- code to be executed before transformer.write() is executed- Returns:
- this
-
withRunVarAccess
Change the behavior for accessing run vars.- Parameters:
runVarAccess- code that retrieves the value for a given key from the given data map- Returns:
- this
-
withTemplate
- Parameters:
templateInputStream- Excel template as InputStream- Returns:
- this
-
withTemplate
- Parameters:
templateURL- Excel template as file defined by an URL- Returns:
- this
- Throws:
IOException
-
withTemplate
- Parameters:
templateFile- Excel template file- Returns:
- this
- Throws:
FileNotFoundException
-
withTemplate
- Parameters:
templateFileName- Excel template file name- Returns:
- this
- Throws:
FileNotFoundException
-