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 ...
随机推荐
- 201521123001《Java程序设计》第1周学习总结
1. 本周学习总结 java和我们以前学的C语言的区别大致有: C语言可以直接操作内存,java不能直接操作: C语言的代码不能跨平台,java的代码可以跨平台: C语言有指针,java没有指针: C ...
- 201521123072《java程序设计》第十周学习总结
201521123072<java程序设计>第十周学习总结 1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常与多线程相关内容. 2. 书面作业 本次PTA作业题集异 ...
- Log4J:Log4J三大组件:Logger+Appender+Layout 格式化编程详解
快速了解Log4J Log4J的三个组件: Logger:日志记录器,负责收集处理日志记录 (如何处理日志) Appender:日志输出目的地,负责日志的输出 (输出到什么 地方) Layo ...
- Java I/O 从0到1 - 第Ⅰ滴血 File
前言 File 类的介绍主要会依据<Java 编程思想>以及官网API .相信大家在日常工作中,肯定会遇到文件流的读取等操作,但是在搜索过程中,并没有找到一个介绍的很简洁明了的文章.因此, ...
- Spring - lookup-method方式实现依赖注入
引言 假设一个单例模式的bean A需要引用另外一个非单例模式的bean B,为了在我们每次引用的时候都能拿到最新的bean B,我们可以让bean A通过实现ApplicationContextWa ...
- temp-存储过程 以前的
---------------------------------------------------------------------------------------------------- ...
- Bootstrap Table急速完美搭建后台管理系统
Bootstrap Table是基于 Bootstrap 的 jQuery 表格插件,通过简单的设置,就可以拥有强大的单选.多选.排序.分页,以及编辑.导出.过滤(扩展)等等的功能:http://bo ...
- ASP.Net开发WebAPI跨域访问(CORS)的精简流程
1: Web.config里有一行: <remove name="OPTIONSVerbHandler" /> 这个要删除. 2: nuget安装Microsoft.A ...
- String类的源码分析
之前面试的时候被问到有没有看过String类的源码,楼主当时就慌了,回来赶紧补一课. 1.构造器(构造方法) String类提供了很多不同的构造器,分别对应了不同的字符串初始化方法,此处从源码中摘录如 ...
- [python学习笔记] 运算符
数学运算符 与大多语言相同的运算符就不介绍了.不同的地方会用 (!不同)标出 与java相同的运算符 , - , * , % , / 不同之处 除法 (!不同) / 与java不同,整数相除,结果为 ...