首页 > 编程语言 > 详细

Java Excel数据导出

时间:2021-01-22 17:01:54      阅读:18      评论:0      收藏:0      [点我收藏+]

导出效果展示
技术分享图片

  相关jar包: pom.xml
	<!-- Excel -->
	<dependency>
		<groupId>cn.afterturn</groupId>
		<artifactId>easypoi-base</artifactId>
		<version>3.2.0</version>
	</dependency>
	<dependency>
		<groupId>cn.afterturn</groupId>
		<artifactId>easypoi-web</artifactId>
		<version>3.2.0</version>
	</dependency>
	<dependency>
		<groupId>cn.afterturn</groupId>
		<artifactId>easypoi-annotation</artifactId>
		<version>3.2.0</version>
	</dependency>

pojo实体类:ExcelCustomerCar; ExcelCustomer;

客户车辆信息
技术分享图片
客户信息
技术分享图片

Controller类

技术分享图片

setExportExcelFormat();方法

  public static void setExportExcelFormat(HttpServletResponse response, Workbook workbook, String fileName) throws Exception {
    response.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(), "ISO8859-1"));
    response.setHeader("Pargam", "no-cache");
    response.setHeader("Cache-Control", "no-cache");
    ServletOutputStream outStream = null;
    try {
        outStream = response.getOutputStream();
        workbook.write(outStream);
    } finally {
        outStream.flush();
        outStream.close();
    }
}

Java Excel数据导出

原文:https://www.cnblogs.com/dawndefend/p/14313260.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!