SpringMvc 关于 EXCEL
概述
我在使用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的更多相关文章
- 用SpringMvc实现Excel导出功能
以前只知道用poi导出Excel,最近用了SpringMvc的Excel导出功能,结合jxl和poi实现,的确比只用Poi好,两种实现方式如下: 一.结合jxl实现: 1.引入jxl的所需jar包: ...
- SpringMVC生成Excel下载
SpringMVC controller里的方法: @RequestMapping(value="/notify/download",produces = {"appli ...
- springmvc 导出excel
1.pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www ...
- springMVC导入excel案例poi
直接上代码: 第一步,controller 引入 private static final String CHECK_FILE = "checkExceFile"; /** * 对 ...
- Springmvc导出Excel(maven)
一.导入依赖 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</ar ...
- springmvc导出excel(POI)
/** * 导出excel表格 */ @RequestMapping(value = "/doExportData", method = {RequestMethod.POST, ...
- springmvc导出excel并弹出下载框
https://my.oschina.net/aptx4869/blog/298507
- springmvc 下载excel
jsp: controller:
- SpringMVC导出Excel
import java.math.BigDecimal; import java.net.URLEncoder; import java.text.SimpleDateFormat; import j ...
随机推荐
- 201521123007《Java程序设计》第3周学习总结
1. 本周学习总结 初学面向对象,会学习到很多碎片化的概念与知识.尝试学会使用思维导图将这些碎片化的概念.知识组织起来.请使用纸笔或者下面的工具画出本周学习到的知识点.截图或者拍照上传. 2. 书面作 ...
- 201521123112《Java程序设计》第13周学习总结
1. 本周学习总结 协议的概念是网络中为了通信而建立的规则,常用的应用层协议有http,ftp等. 测试计算机之间的网络是否连通可以使用ping命令. 可以使用IP+端口号的方法来确定数据包是发给哪个 ...
- 多线程:多线程设计模式(二):Future模式
一.什么是Future模型: 该模型是将异步请求和代理模式联合的模型产物.类似商品订单模型.见下图: 客户端发送一个长时间的请求,服务端不需等待该数据处理完成便立即返回一个伪造的代理数据(相当于商品订 ...
- JAVA多线程高并发学习笔记(三)——Callable、Future和FutureTask
为什么要是用Callable和Future Runnable的局限性 Executor采用Runnable作为基本的表达形式,虽然Runnable的run方法能够写入日志,写入文件,写入数据库等操作, ...
- 通过Excel认识POI
1.POI是什么 Apache POI - the Java API for Microsoft Documents,顾名思义,Apache的三方包,用来操作微软office文档的,多数时候用来操作e ...
- python实例编写(5)--异常处理,截图,用例设计
一.python的异常处理 异常抛出处理机制: 1.若在运行时发生异常,解释器会查找相应的处理语句(handler) 2.若在当前函数无法找到,就将异常传给上层的调用函数,看是否能处理 3.如果在最外 ...
- 教你在Java接口中定义方法
基本上所有的Java教程都会告诉我们Java接口的方法都是public.abstract类型的,没有方法体的. 但是在JDK8里面,你是可以突破这个界限的哦. 假设我们现在有一个接口:TimeClie ...
- oracle数据库使用心得之与SQL serve数据库的差异
网上对于SQL数据库的使用比较详细,但是对于Oracle的使用比较少,本文特别适合学过SQL数据库但是工程需要使用Oracle数据的编程人员查看, 时间匆忙,文章可能写得不够详细,希望有人指出错误或者 ...
- java GUI编程一
一.AWT介绍 所有的可以显示出来的图形元素都称为Component,Component代表了所有的可见的图形元素,Component里面有一种比较特殊的图形元素叫Container,Containe ...
- 为什么要用深度学习来做个性化推荐 CTR 预估
欢迎大家前往腾讯云技术社区,获取更多腾讯海量技术实践干货哦~ 作者:苏博览 深度学习应该这一两年计算机圈子里最热的一个词了.基于深度学习,工程师们在图像,语音,NLP等领域都取得了令人振奋的进展.而深 ...