Friday, November 2, 2018

Spring RESTful Web service to generate downloadable Excel as response using JExcel API and Apache POI

JExcelApi is a Java library that is dedicated for reading, writing and modifying Excel spreadsheets. It supports Excel 2003 file format and older versions. You can download JExcelApi from the following link:

To work with JExcelApi, you need to add its only jar file: jxl.jar - to your project’s classpath. Download JExcel

Here we are going to create spring API to download Excel file as response using JExcel Api.



Now call the service as :
http://localhost:8080/demo/excelOutputService/download
This will download the Excel file to download folder or show download popup window.


Create Excel using Apache POI

POI-XSSF - Java API To Access Microsoft Excel Format Files
Apache POI is a popular API that allows programmers to create, modify, and display MS Office files using Java programs.
XSSF is the POI Project's pure Java implementation of the Excel 2007 OOXML (.xlsx) file format.

Prerequisites
· DK1.5 or later versions
· Apache POlibrary (http://poi.apache.org/download.html )

Add following library to classpath:
“C:\poi-3.9\poi-3.9-20121203.jar;”
“C:\poi-3.9\poi-ooxml-3.9-20121203.jar;”
“C:\poi-3.9\poi-ooxml-schemas-3.9-20121203.jar;”
“C:\poi-3.9\ooxml-lib\dom4j-1.6.1.jar;”
“C:\poi-3.9\ooxml-lib\xmlbeans-2.3.0.jar;.;”



Read / Write Excel file (.xls or .xlsx) using Apache POI : Full Example

References:
https://aboullaite.me/spring-boot-excel-csv-and-pdf-view-example/
http://simplejava2.blogspot.com/

0 comments:

Post a Comment

Contact

Get in touch with me


Adress/Street

Bangalore, India