Community contributed extensions

Excel module

The Excel module allows you to render Excel document. It is rather simple to use as it only requires to import a static file.

The tool uses the jxls library.

In order to use the Excel module, you need to create an Excel based template – see http://jxls.sourceforge.net for details instruction.

What’s New in v1.2.3

What’s New in v1.2.2

What’s New in v1.2.1

What’s New in v1.2

Note,

What’s New in v1.0a

Enable the Excel module for the application

In the /conf/application.conf file, enable the Excel module by adding this line:

# The Excel module
module.Excel=${play.path}/modules/Excel
excel.template.root=app/views

note:

Using the Excel module

The renderExcel() method (only apply for versions before v1.2):

import static play.modules.excel.Excel.*;

And then use the renderExcel() method as you would use the render() method.

The renderExcel() behavior is almost the same as that of render() except the following differences:

  1. the template should be an excel file with “.xls” suffix rather than a text file with ".html"
  2. You can use renderArgs.put(“fileName”, “your-file.xls”) to indicate the name of the excel file to be generated

Set request.format New in v1.2

Set request.format to ‘xls’ or ‘xlsx’ to render user Excel template. The excel template should be put in the same dir as normal html template, the file suffix shall comply with request.format setting. An easy way to set request.format is via route configuration. Please refer to http://www.playframework.org/documentation/1.2.1/routes#content-types for detail.

For v1.2 and v1.2.1 please make sure you have @With(ExcelControllerHelper.class) annotation on your controller class if you want to generate Excel report. This is no longer needed for v1.2.2

Please refer to the sample for an example.