public class JxlsHelper extends Object
| Constructor and Description |
|---|
JxlsHelper() |
| Modifier and Type | Method and Description |
|---|---|
JxlsHelper |
buildExpressionNotation(String expressionNotationBegin,
String expressionNotationEnd)
Allows to set custom notation for expressions in the template The notation is
used in
createTransformer(InputStream, OutputStream) |
ExpressionEvaluator |
createExpressionEvaluator(String expression)
Creates
ExpressionEvaluator instance for evaluation of the given expression |
Transformer |
createTransformer(InputStream templateStream,
OutputStream targetStream)
Creates
Transformer instance connected to the given input stream and
output stream with the default or custom expression notation (see also
buildExpressionNotation(String, String) |
AreaBuilder |
getAreaBuilder() |
ExpressionEvaluatorFactory |
getExpressionEvaluatorFactory() |
FormulaProcessor |
getFormulaProcessor() |
static JxlsHelper |
getInstance()
Returns new JxlsHelper instance
|
static String |
getProperty(String key,
String defaultValue)
Returns the configuration property value
|
JxlsHelper |
gridExport(Collection<?> headers,
Collection<?> dataObjects,
String objectProps,
OutputStream outputStream)
Performs data grid export using
SimpleExporter |
boolean |
isDeleteTemplateSheet() |
boolean |
isEvaluateFormulas()
This property is used to recalculate all formulas before saving the workbook.
|
boolean |
isFullFormulaRecalculationOnOpening() |
boolean |
isHideTemplateSheet() |
boolean |
isProcessFormulas() |
boolean |
isUseFastFormulaProcessor() |
JxlsHelper |
processGridTemplate(InputStream templateStream,
OutputStream targetStream,
Context context,
String objectProps)
Processes the template with the
GridCommand |
void |
processGridTemplateAtCell(InputStream templateStream,
OutputStream targetStream,
Context context,
String objectProps,
String targetCell)
Processes the input template with
GridCommand at given target cell
using the given object properties and context |
void |
processTemplate(Context context,
Transformer transformer)
Processes a template with the given
Transformer instance and Context |
JxlsHelper |
processTemplate(InputStream templateStream,
OutputStream targetStream,
Context context)
Reads template from the source stream processes it using the supplied
Context and writes the result to the target stream |
JxlsHelper |
processTemplateAtCell(InputStream templateStream,
OutputStream targetStream,
Context context,
String targetCell)
Processes the template from the given input stream using the supplied
Context and the given target cell and writes the result to the output stream |
JxlsHelper |
registerGridTemplate(InputStream inputStream)
Registers grid template to be used with
SimpleExporter |
JxlsHelper |
setAreaBuilder(AreaBuilder areaBuilder) |
JxlsHelper |
setDeleteTemplateSheet(boolean deleteTemplateSheet)
Marks template sheet for deletion
|
JxlsHelper |
setEvaluateFormulas(boolean evaluateFormulas)
This property is used to recalculate all formulas before saving the workbook.
|
JxlsHelper |
setFormulaProcessor(FormulaProcessor formulaProcessor)
Sets formula processor implementation
|
JxlsHelper |
setFullFormulaRecalculationOnOpening(boolean fullFormulaRecalculationOnOpening)
If you set this option to true, all formulas will be recalculated when the file is opened in MS Excel.
|
JxlsHelper |
setHideTemplateSheet(boolean hideTemplateSheet)
Hides/shows template sheet
|
JxlsHelper |
setProcessFormulas(boolean processFormulas)
Enables or disables formula processing
|
JxlsHelper |
setUseFastFormulaProcessor(boolean useFastFormulaProcessor) |
public static JxlsHelper getInstance()
public boolean isEvaluateFormulas()
workbook.getCreationHelper().createFormulaEvaluator().evaluateAll()
before writing the workbook. Please have a look at the POI documentation for more details.
This does not work for streaming.
Please be aware that POI supports only a subset of Excel formulas.
If an unsupported formula is in the template the evaluation will fail.
false (default): do nothing (hopefully MS Excel will recalculate all formulas while opening the file)
public JxlsHelper setEvaluateFormulas(boolean evaluateFormulas)
Don't do this:
JxlsHelper.getInstance().setEvaluateFormulas(true);
JxlsHelper.getInstance().processTemplate(...);
Call JxlsHelper.getInstance() only once!
The following documentation is POI specific.
evaluateFormulas - true: calls workbook.getCreationHelper().createFormulaEvaluator().evaluateAll()
before writing the workbook. Please have a look at the POI documentation for more details.
This does not work for streaming.
Please be aware that POI supports only a subset of Excel formulas.
If an unsupported formula is in the template the evaluation will fail.
false (default): do nothing (hopefully MS Excel will recalculate all formulas while opening the file)
public boolean isFullFormulaRecalculationOnOpening()
public JxlsHelper setFullFormulaRecalculationOnOpening(boolean fullFormulaRecalculationOnOpening)
fullFormulaRecalculationOnOpening - false: do nothing (default value),
true: activate recalculation when openingpublic AreaBuilder getAreaBuilder()
public JxlsHelper setAreaBuilder(AreaBuilder areaBuilder)
public FormulaProcessor getFormulaProcessor()
FormulaProcessor implementationpublic JxlsHelper setFormulaProcessor(FormulaProcessor formulaProcessor)
formulaProcessor - FormulaProcessor instancepublic boolean isProcessFormulas()
public JxlsHelper setProcessFormulas(boolean processFormulas)
processFormulas - enable/disable formula processing flagpublic boolean isHideTemplateSheet()
public JxlsHelper setHideTemplateSheet(boolean hideTemplateSheet)
hideTemplateSheet - true to hide template sheet or false to show itpublic boolean isDeleteTemplateSheet()
public JxlsHelper setDeleteTemplateSheet(boolean deleteTemplateSheet)
deleteTemplateSheet - true if template sheet should be deletedpublic boolean isUseFastFormulaProcessor()
FastFormulaProcessor should be usedpublic JxlsHelper setUseFastFormulaProcessor(boolean useFastFormulaProcessor)
useFastFormulaProcessor - if true the FastFormulaProcessor will be used to process formulas
otherwise StandardFormulaProcessor will be usedpublic JxlsHelper buildExpressionNotation(String expressionNotationBegin, String expressionNotationEnd)
createTransformer(InputStream, OutputStream)expressionNotationBegin - notation prefixexpressionNotationEnd - notation suffixpublic JxlsHelper processTemplate(InputStream templateStream, OutputStream targetStream, Context context) throws IOException
Context and writes the result to the target streamtemplateStream - source input stream with the templatetargetStream - target output streamcontext - data mapIOException - -public void processTemplate(Context context, Transformer transformer) throws IOException
Transformer instance and Contextcontext - data contexttransformer - transformer instanceIOException - -public static String getProperty(String key, String defaultValue)
key - property keydefaultValue - default value to use if undefinedpublic ExpressionEvaluatorFactory getExpressionEvaluatorFactory()
ExpressionEvaluatorFactory implementationpublic ExpressionEvaluator createExpressionEvaluator(String expression)
ExpressionEvaluator instance for evaluation of the given expressionexpression - expression to evaluateExpressionEvaluator instance for evaluation the passed expressionpublic JxlsHelper processTemplateAtCell(InputStream templateStream, OutputStream targetStream, Context context, String targetCell) throws IOException
Context and the given target cell and writes the result to the output streamtemplateStream - source input stream for the templatetargetStream - target output stream to write the processing resultcontext - data maptargetCell - starting target cell into which the template area must be processedIOException - if input/output stream processing resolves in an errorpublic JxlsHelper processGridTemplate(InputStream templateStream, OutputStream targetStream, Context context, String objectProps) throws IOException
GridCommandtemplateStream - template input streamtargetStream - output stream for the resultcontext - data mapobjectProps - object properties to use with the GridCommandIOException - -public void processGridTemplateAtCell(InputStream templateStream, OutputStream targetStream, Context context, String objectProps, String targetCell) throws IOException
GridCommand at given target cell
using the given object properties and contexttemplateStream - template input streamtargetStream - result output streamcontext - data mapobjectProps - object properties to use with GridCommandtargetCell - start target cell to use when processing the templateIOException - -public JxlsHelper registerGridTemplate(InputStream inputStream) throws IOException
SimpleExporterinputStream - template input streamIOException - -public JxlsHelper gridExport(Collection<?> headers, Collection<?> dataObjects, String objectProps, OutputStream outputStream)
SimpleExporterheaders - collection of headers to use for the exportdataObjects - collection of data objects to exportobjectProps - object properties (comma separated) to use with the GridCommandoutputStream - output stream to write the processing resultpublic Transformer createTransformer(InputStream templateStream, OutputStream targetStream)
Transformer instance connected to the given input stream and
output stream with the default or custom expression notation (see also
buildExpressionNotation(String, String)templateStream - source template input streamtargetStream - target output stream to write the processing resultCopyright © 2023. All rights reserved.