Excel Export in Spring MVC
Export as excel is one of the most wanted feature in an enterprise application. In this tutorial let us learn about export as excel feature using Spring MVC framework. If you are a beginner, go through the Spring MVC tutorial before taking this. We will be using Spring 3 annotation based approach for the web application.
If you have learned Spring MVC, there is not much to discuss, in this excel export tutorial. All you have to know is, Spring provides a class AbstractExcelView which is a view in the MVC. We need to extend this class and write our custom classes. Then configure our custom class as the view in the MVC.
- Extend AbstractExcelView and write a custom excel view. There is a method buildExcelDocument in this class, which we should override to build the excel.
- Configure the new custom class, which we have created as the view in the Spring MVC. We should imagine this new java class file as a replacement for the JSP which we generally will have in the view.
Do not call the service layer or DAO directly from the view class. Similarly, it should not contain the business logic of the application. Call to service/business should happen from the controller and the model should be built. Only the model should be sent to the view. This view class, should just construct the excel header, rows and formatting.
Maven is used to manage the dependencies. If you do not have Maven, it is better to download and setup Maven.
ref.> http://javapapers.com/spring/excel-export-in-spring-mvc/
기타
http://www.codejava.net/coding/how-to-write-excel-files-in-java-using-apache-poi
http://www.codejava.net/frameworks/spring/spring-mvc-with-excel-view-example-apache-poi-and-jexcelapi
'◆ 무한한 가능성 > & JAVA' 카테고리의 다른 글
아마존 EC2 Java8 install 설치 (Amazon, AWS) (0) | 2017.04.18 |
---|---|
서블릿(자바,JAVA)에서 JSP를 호출 (0) | 2017.02.22 |
자바(JAVA) 형 변환(String to Date, Date to String) (0) | 2016.03.21 |
JAVA ini 파일 읽고 쓰기 (0) | 2016.03.17 |
JAVA - 한글 인코딩 변환 체크 한방에 끝내기 (0) | 2016.03.13 |