Open Source Java Library for Spreadsheet Documents

Free Java Library for Excel Report Generation that uses special markup in Excel templates to define output formatting.

What is JXLS?

JXLS is a very powerful open source Java report generation library that allows software developers to create Excel reports using Excel templates. It is a wrapper around existing open source projects known by the name of Apache POI. The library is very simple to use and abstracts Excel generation from an underlying Java-to-Excel low-level processing library.

The JXLS library uses a special markup in Excel templates to define output formatting and data layout. There are many other low level Java libraries that require developers to write a lot of Java code to for accomplishing a small task. On the other hand for JXLS library users need to outline the required report formatting and data layout in an Excel template file and after that need to fill in the template with data by running JXLS engine. It makes the developer job easy by allowing them to write just a little bit of Java code to accomplish a task.

The JXLS library has included support for several important features related to spreadsheet reporting, such as XML and binary Excel format output, Native Excel formulas, parameterized formulas, grouping support, merged cells support, expression language in report definition markup, multiple sheets output, area listeners to adjust excel generation, excel comments mark-up for command definition, Table support and so on.

Previous Next

Getting Started with JXLS

The recommend way to add JXLS libraries to your project is to use Maven and specify the required libraries in your project build configuration file.

JXLS Maven Dependency

<dependency>
<groupId>org.jxls</groupId>
<artifactId>jxls</artifactId>
<version>2.10.0</version>
</dependency>

You can also download the compiled shared library from the GitHub repository and install it.

How to Generate Report using Java API/h2>

The open source JXLS library enables software developers to generate reports quickly with highly presentable and useful information using Java code. Most of the libraries do it manually and needs a lot of code to create such reports. With JXLS it is very easy to achieve this entire formatting using Excel template. Apart from creating the reports, the library is also very useful in uploading bulk data using Excel.

Generate Excel Report via Java APi

Path dirpath = Paths.get(exportDirectory);
String filename = dirpath.resolve(UUID.randomUUID().toString() + ".xls").toString();
try (InputStream is = StudentService.class.getClassLoader().getResourceAsStream("student.xls"))
{
 try (OutputStream os = new FileOutputStream(filename))
 {
   Context context = new Context();
   context.putVar("students", students);
   JxlsHelper.getInstance().processTemplate(is, os, context);
 }
}
return filename;

Multiple Sheets Support inside Java Apps

The open source JXLS -Java library enables software developers to create multiple sheets at runtime using Java commands. Once created you need to specify a unique name to the sheet and if there are not enough sheet names or a sheet name is not valid or not unique an ERROR message will be printed to the log and the sheet will not be generated. You can use the items property that defines how many sheets are created at runtime.

Use Excel Formulas in Reports via Java Library

The open source JXLS library allows software developers to generate customized reports using an excel template. The library provides complete support for using standard Excel formulas as well as parameterized formulas defined with a special syntax inside the reports. The great thing is that the formulas will be processed by default when processing the template and no extra code is needed. If want to use more complicated formulas which Apache POI cannot handle, the developers need to save a hint in the Workbook which guide the Excel to recalculate all formulas on reopening.

 English