We wanted to switch from Java 8 to Java 17. A Logback update was necessary for this. This proved difficult as the Logback XML feature (Joran) has changed massively. We therefore decided to remove the XML feature and make a major release 3. We believe that no one has used the XML feature. (If this isn't the case, the community is welcome to recreate the XML feature for v3 - with a better XML technology.)
We ended up removing Logback entirely. We used version 3 for further extensive revisions, while the core remained unchanged.
SLF4J has also been removed and replaced with the JxlsLogger interface.
The new builder API replaces JxlsHelper. All options can now be set in the builder with a Fluent API. This now makes it possible to create reports with completely different options in parallel. The TransformerFactory and createTransformer() methods have also been removed.
Context is now no longer just seen as a Map holder, but should in the future contain all the information necessary for creating reports. Context is now an internal interface. The data is passed to the JxlsTemplateFiller as Map<String, Object>; i.e. without Context. Sometimes classes need Context access. There is the PublicContext interface and the builder method needsPublicContext() for this. TransformationConfig was renamed to ExpressionEvaluatorContext and moved from the Transformer to the Context. This means that expression evaluations are now done via the Context.
Another design goal was the possibility of exchanging classes.
A new strategy is that it should be possible to add new commands without having to change the Transformer.
The documentation has been completely rewritten and our website has a new design.
In addition to the "note lastCell" command syntax from version 2, we have a new alternative "note marker" syntax in the pipeline. See MarkerAreaBuilder.
Sorry for the trouble the updating will take. But Jxls is a hobby project and the hard transition was less effort. The templates do not need to be changed. You can stay with 2.14.0 for a while. If there are important bug fixes, we will also make them there if necessary.
Removals
Replacements
New Features
sheetStreaming="true"
in a note (see JxlsStreaming.AUTO_DETECT)TL;DR: use Map<String, Object> instead of Context and use JxlsPoiTemplateFillerBuilder instead of JxlsHelper.
I had to switch to Jxls 3 myself and here are these tips from the experience I had:
JxlsHelper.getInstance()
use JxlsPoiTemplateFillerBuilder.newInstance()
. (See builder options documentation)builder.needsPublicContext(customFunctions)
and implement NeedsPublicContext interface on your custom functions class to retrieve the PublicContext. Evaluations can be done using the PublicContext.new JexlExpressionEvaluator(expression).evaluate(context.toMap());
you can now use context.evaluate(expression)
JxlsHelper.getInstance().createExpressionEvaluator(null).evaluate(condition, context.toMap())
to evaluate a condition which returns a boolean you can now use: new ExpressionEvaluatorFactoryJexlImpl().createExpressionEvaluator(null).isConditionTrue(condition, data)
transformer.write()
you can call builder.withPreWriteAction((transformer, publicContext) -> ...)
builder.buildAndFill(data)
and get a byte[]builder.withExpressionEvaluatorFactory(new ExpressionEvaluatorFactoryJexlImpl(true));
and also do this: builder.withLogger(new PoiExceptionThrower())
for getting exceptions if something went wrong. Old Jxls 2 code was like this for that: transformer.getTransformationConfig().setExpressionEvaluator(new JexlExpressionEvaluator(false, true)); transformer.setExceptionHandler(new PoiExceptionThrower());
context.getConfig().setIsFormulaProcessingRequired(false);
you must now call builder.withUpdateCellDataArea(false)
builder.withStreaming(JxlsStreaming.AUTO_DETECT)
.copy(InputStream, OutputStream)
method in ImageCommand. You possibly have to change your templates.