1:通过自定义的View视图可以让请求直接到一个Excel表去。
2:自定义的视图必须继承 AbstractXlsView /AbstractXlsxView / AbstractXlsxStreamingView其中的一个抽象类,并实现buildExcelDocument方法;
3:如果使用的org.springframework.web版本比较老,继承的是AbstractExcelView类,所以说这个类已经过时了。
具体实现:
1.使用Maven或者Gradle导包,这里以Gradle为例。
dependencies { compile group: 'org.springframework', name: 'spring-webmvc', version: '5.0.4.RELEASE' compile group: 'org.springframework', name: 'spring-context', version: '5.0.5.RELEASE' compile group: 'org.springframework', name: 'spring-web', version: '5.0.5.RELEASE' compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0' compile group: 'javax.servlet', name: 'jsp-api', version: '2.0' /*poi生成Excel*/ compile group: 'org.apache.poi', name: 'poi', version: '4.0.1' compile group: 'org.apache.poi', name: 'poi-ooxml', version: '4.0.1' testCompile group: 'junit', name: 'junit', version: '4.12' }