1:通过自定义的View视图可以让请求直接到一个Excel表去。

2:自定义的视图必须继承  AbstractXlsView /AbstractXlsxView / AbstractXlsxStreamingView其中的一个抽象类,并实现buildExcelDocument方法;

3:如果使用的org.springframework.web版本比较老,继承的是AbstractExcelView类,所以说这个类已经过时了。


 

具体实现:

1.使用Maven或者Gradle导包,这里以Gradle为例。

springMvc使用自定义View生成Excel表格
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'
}
View Code

相关文章:

  • 2021-07-22
  • 2021-07-31
  • 2021-10-19
  • 2021-11-23
  • 2022-01-05
  • 2021-12-05
  • 2021-08-06
猜你喜欢
  • 2021-12-27
  • 2021-11-17
  • 2022-01-28
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案