POI-Ecel模板导出
/**
*
* @param excelPath excel模板路径
* @param downloadPath 文件下载路径
* @param list 报表数据
* @param response
* @return
* @throws Exception
*/
@SuppressWarnings("resource")
public AjaxResult excel(String excelPath, String downloadPath, List<QuestionReport> list, HttpServletResponse response) throws Exception{
OutputStream out = null;
//获取excel模板路径
File fi = new File(excelPath);
//获取文件名称
String fileName = fi.getName();
//读取excel模板
InputStream inp = new FileInputStream(fi);
//创建xlsx-excel文件
XSSFWorkbook wb = new XSSFWorkbook(inp);
//获取第一个sheet
XSSFSheet sheet = wb.getSheetAt(0);
//填充数据
for (int i = 0; i < list.size(); i++) {
//从第三行开始创建
XSSFRow row = sheet.createRow(2 + i);
QuestionReport questionReport = list.get(i);
//填充第三行第一个数据
row.createCell(0).setCellValue(1 + i);
row.createCell(1).setCellValue(questionReport.getProjectCode());
row.createCell(2).setCellValue(questionReport.getProjectName());
row.createCell(3).setCellValue(questionReport.getProjectDept());
row.createCell(4).setCellValue(questionReport.getBuildQualityHead());
row.createCell(5).setCellValue(questionReport.getProjectBuildingNos());
row.createCell(6).setCellValue(questionReport.getZlQuestion());
row.createCell(7).setCellValue(questionReport.getZlYZG());
row.createCell(8).setCellValue(questionReport.getZlDzg());
row.createCell(9).setCellValue(questionReport.getAqQuestion());
row.createCell(10).setCellValue(questionReport.getAqYZG());
row.createCell(11).setCellValue(questionReport.getAqDzg());
row.createCell(12).setCellValue(questionReport.getCbQuestion());
row.createCell(13).setCellValue(questionReport.getCbYZG());
row.createCell(14).setCellValue(questionReport.getCbDzg());
row.createCell(15).setCellValue(questionReport.getCbQuestion());
row.createCell(16).setCellValue(questionReport.getCbYZG());
row.createCell(17).setCellValue(questionReport.getCbDzg());
}
//修改模板内容导出新模板
fileName ="报事工单报表" + ".xlsx";
out = new FileOutputStream(downloadPath + fileName);
wb.write(out);
out.close();
out.flush();
return AjaxResult.success(fileName);
}
POI-Ecel模板导出相关推荐
- POI根据模板导出word文件,以及word转PDF,PDF转图片再插入PDF中(防止PDF被修改)
POI操作word和PDF POI根据模板导出word文件 word转PDF PDF转图片再插入PDF中(防止PDF被修改) POI根据模板导出word文件 一.制作word模版,${xxxx}是一会 ...
- poi 使用模板导出数据
poi 使用模板导出数据 引入依赖 代码 错误 POI 操作Excel 出现如下异常 xlsx模板自己随便建一个放在resource目录下就行,测试代码以及遇到的报错问题如下: 引入依赖 <!- ...
- 【springboot+poi+poi-tl 模板导出wrod (包含图片集合、页眉、页脚)】
springboot+poi+poi-tl 模板导出wrod 1. maven依赖 <dependency><groupId>org.apache.poi</groupI ...
- POI按照模板导出Excel数据
一:所需jar包如下 二:ExportExcelUtil.java package com.upsoft.exportexcel; import java.io.FileInputStream; im ...
- poi根据模板导出word(包含图片、动态生成表格、合并单元格)(亲测有效)
准备工作: 1.需要的jar(jar包在资源处已上传,可下载) 2.创建docx模板(doc不可以) 第一步:准备好jar(这里面的 ooxml-schemas-1.1.jar 大家可以尝试用poi- ...
- poi使用模板导出word带图片
1.下面是我做的加载模板导出带图片的word的导出方式,使用之前请映入freemarker的jar包,可以从百度下载即可. 2.首先准备到你要导出的word模板,在要填充的模板中填入el表达式,如下图 ...
- java poi导出excel模板_POI通过模板导出EXCEL文件的实例
一般的EXCEL导出使用POI先创建一个HSSFWorkbook,然后通过不断创建HSSFRow,HSSFCell后设置单元格内容便可以完成导出. 这次在项目中需要用到模板,导出的内容包括(1.模板中 ...
- 【Apache POI】Java Web根据模板导出word文件
最近工作中遇到一个需求:根据word模板文档导出word文件. 查阅了一些资料,发现Apache POI可以实现文档读写的功能,于是就研究了一下,总结如下: Apache-POI在线Javadoc:h ...
- 图片复制word java_java poi实现word导出(包括word模板的使用、复制表格、复制行、插入图片的使用)...
java poi实现数据的word导出(包括word模板的使用.复制表格.复制行.插入图片的使用) 1.实现的效果 实现病人基本信息.多条病历数据.多项检查项图片的动态插入(网络图片) 2.模板 把w ...
- springboot+poi开发excel导出 加载Excel模板导出 Excel批量导出详解
提到Excel导出功能,可能很多人都使用springmvc框架做过,笔者今天要给大家分享的是基于springBoot开发Excel复杂模板导出功能(所谓复杂模板指在模板里的特定表头里有不同的单元格合并 ...
最新文章
- ASP.NET 如何动态修改 title Meta link标签
- MySQL 数据格式化
- 在64位系统上注册并使用32位的COM组件
- 【APICloud系列|24】 MNNavigationMenu模块(导航菜单)的实现
- web service 学习 2 -- 什么时候应该使用web service
- 深入阅读Mina源码(3) —— Mina之IOAdapter(二)
- Elasticsearch 安装随笔
- MVC 19个通信(请求)管道
- MySQL用什么输入法_最好用的输入法是什么?
- mysql 仓储系统规划与设计,仓库管理系统的设计与实现.doc
- 算法与数据结构全阶班-左程云版系列目录
- [转载]论原著中白飞飞和朱七七两大奇女子
- 如何批量下载央视CNTV的节目视频
- [ARCGIS]带黑边的IMG格式影像如何消除黑边?
- c51实现老人跌倒,心率异常报警系统
- Robocup新手指南
- 管理学生营养餐很重要
- JS- 数字自增动画
- python分析股票数据 彤_Python数据分析:股票数据
- asp 和 html 婚鞋,几招教会你搭配出完美婚鞋