

We will end up with the following project structure:

In Eclipse IDE, create a Dynamic Web Project called SpringMvcExcelViewDemo.

However, you can also download a JExcelApi version of the project in the Attachments section. This tutorial will use Apache POI for the sample application. And Spring provides an abstract class called AbstractJExcelView which should be extended to generate an Excel document using JExcelApi, similarly to the case of Apache POI. To work with JExcelApi, you need to add its only jar file: jxl.jar - to your project’s classpath. You can download JExcelApi from the following link: It supports Excel 2003 file format and older versions. JExcelApi is a Java library that is dedicated for reading, writing and modifying Excel spreadsheets. Then using Apache POI’s Excel API to generate the excel document. To generate an Excel document using Apache POI within Spring, we need to create a view class that extends from the AbstractExcelView class and override its method buildExcelDocument(). The distribution comes with several jar files, but the only the poi-VERSION.jar file is required for typical usage of generating Excel documents (if you want to generate Excel XML format such as *.xlsx files, use the poi-ooxml-VERSION.jar file). Click the following link to download its latest distribution (which is Apache POI 3.9, as of this writing): Apache POI is a set of pure Java libraries for reading and writing Microsoft Office documents such as Word, Excel, Powerpoint, Outlook, etc.
