概述

我在使用SpingMvc 的EXCEL的发现传统的

  • AbstractJExcelView jexcel api已经过时
  • AbstractView poi Api

    通过阅读官方文档发现建议我们使用
  • AbstractXlsView
  • AbstractXlsxView
  • AbstractXlsxStreamingView

Deprecated. as of Spring 4.2, in favor of AbstractXlsView and its AbstractXlsxView and AbstractXlsxStreamingView variants Convenient superclass for Excel document views. Compatible with Apache POI 3.5 and higher, as of Spring 4.0. Properties:
•url (optional): The url of an existing Excel document to pick as a starting point. It is done without localization part nor the ".xls" extension.
  • 这里我们写一个例子:
package myview;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.view.document.AbstractXlsView; @Component
public class MyExcelView extends AbstractXlsView {
/**
* AbstractJExcelView jexcel api已经过时
* AbstractView poi Api
* 简单定义的显示excel数据内容
*/
@Override
protected void buildExcelDocument(Map<String, Object> model, Workbook workbook, HttpServletRequest request,
HttpServletResponse response) throws Exception {
response.setHeader("content-disposition", "attachment;filename=我的工作簿.xls");
Sheet sheet = workbook.createSheet("我的工作簿");
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
Cell cell2 = row.createCell(1);
cell.setCellValue("1");
cell2.setCellValue("2");
}
}

SpringMvc 关于 EXCEL的更多相关文章

  1. 用SpringMvc实现Excel导出功能

    以前只知道用poi导出Excel,最近用了SpringMvc的Excel导出功能,结合jxl和poi实现,的确比只用Poi好,两种实现方式如下: 一.结合jxl实现: 1.引入jxl的所需jar包: ...

  2. SpringMVC生成Excel下载

    SpringMVC controller里的方法: @RequestMapping(value="/notify/download",produces = {"appli ...

  3. springmvc 导出excel

    1.pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www ...

  4. springMVC导入excel案例poi

    直接上代码: 第一步,controller 引入 private static final String CHECK_FILE = "checkExceFile"; /** * 对 ...

  5. Springmvc导出Excel(maven)

    一.导入依赖 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</ar ...

  6. springmvc导出excel(POI)

    /** * 导出excel表格 */ @RequestMapping(value = "/doExportData", method = {RequestMethod.POST, ...

  7. springmvc导出excel并弹出下载框

    https://my.oschina.net/aptx4869/blog/298507

  8. springmvc 下载excel

    jsp: controller:

  9. SpringMVC导出Excel

    import java.math.BigDecimal; import java.net.URLEncoder; import java.text.SimpleDateFormat; import j ...

随机推荐

  1. 201521123003《Java程序设计》第12周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多流与文件相关内容. 2. 书面作业 将Student对象(属性:int id, String name,int age,doubl ...

  2. Hibernate第七篇【对象状态、一级缓存】

    前言 本博文主要讲解Hibernate的细节-->对象的状态和一级缓存- 对象状态 Hibernate中对象的状态: - 临时/瞬时状态 - 持久化状态 - 游离状态 学习Hibernate的对 ...

  3. Socket类 以及 ServerSocket类 讲解

    Socket类 套接字是网络连接的端点,套接字使应用可以从网络中读取数据,可以向网络中写入数据.不同计算机上的两个应用程序可以通过连接发送或接收字节流,以此达到相互通信的目的. 为了从一个应用程序向另 ...

  4. BlockingQueue<> 队列的作用

    BlockingQueue<> 队列的作用 BlockingQueue 实现主要用于生产者-使用者队列 BlockingQueue 实现主要用于生产者-使用者队列,BlockingQueu ...

  5. 再起航,我的学习笔记之JavaScript设计模式24(备忘录模式)

    备忘录模式 概念介绍 备忘录模式(Memento): 在不破坏对象的封装性的前提下,在对象之外捕获并保存该对象内部的状态以便日后对象使用或者对象恢复到以前的某个状态. 简易分页 在一般情况下我们需要做 ...

  6. Cross the GreateWall方案

    涉及Client端和Server端 服务端:SS搭建 注意:以Ubuntu环境为例 Step1:添加GPG Public key wget -O- http://shadowsocks.org/deb ...

  7. openGPS.cn - 高精度IP定位原理,定位误差说明

    [ip定位历史] 关于IP定位,最早是通过运营商实现,每个运营商申请到的ip段,在某个范围内使用. 因此早期只能是国家为单位的基础数据. 对于比较大的国家,就进一步划分,比如,中国某通讯公司(不打广告 ...

  8. VCL组件之TLabel、TStaticText和TLabeledEdit

    TLabel.TStaticText.TLabeledEdit类的继承关系如下:

  9. hdu 2609 How many 最小表示法

    How many Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  10. SQL Server 后悔药 delete drop update

    国庆假期终于有时间做点事情 因为平常工作会做些数据库操作 可能会有所操作失误  参考一下 方法一 ApexSql 2016一个软件 http://www.cnblogs.com/gsyifan/p/A ...