◆ 무한한 가능성/& JAVA

Excel Export in Spring MVC. 자바 스프링에서 엑셀저장 엑셀다운로드

치로로 2016. 5. 15. 21:46

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.

  1. Extend AbstractExcelView and write a custom excel view. There is a method buildExcelDocument in this class, which we should override to build the excel.
  2. 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/



ExcelExportSpringMVC.zip











기타

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