/**
     * 
     * @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模板导出相关推荐

  1. POI根据模板导出word文件,以及word转PDF,PDF转图片再插入PDF中(防止PDF被修改)

    POI操作word和PDF POI根据模板导出word文件 word转PDF PDF转图片再插入PDF中(防止PDF被修改) POI根据模板导出word文件 一.制作word模版,${xxxx}是一会 ...

  2. poi 使用模板导出数据

    poi 使用模板导出数据 引入依赖 代码 错误 POI 操作Excel 出现如下异常 xlsx模板自己随便建一个放在resource目录下就行,测试代码以及遇到的报错问题如下: 引入依赖 <!- ...

  3. 【springboot+poi+poi-tl 模板导出wrod (包含图片集合、页眉、页脚)】

    springboot+poi+poi-tl 模板导出wrod 1. maven依赖 <dependency><groupId>org.apache.poi</groupI ...

  4. POI按照模板导出Excel数据

    一:所需jar包如下 二:ExportExcelUtil.java package com.upsoft.exportexcel; import java.io.FileInputStream; im ...

  5. poi根据模板导出word(包含图片、动态生成表格、合并单元格)(亲测有效)

    准备工作: 1.需要的jar(jar包在资源处已上传,可下载) 2.创建docx模板(doc不可以) 第一步:准备好jar(这里面的 ooxml-schemas-1.1.jar 大家可以尝试用poi- ...

  6. poi使用模板导出word带图片

    1.下面是我做的加载模板导出带图片的word的导出方式,使用之前请映入freemarker的jar包,可以从百度下载即可. 2.首先准备到你要导出的word模板,在要填充的模板中填入el表达式,如下图 ...

  7. java poi导出excel模板_POI通过模板导出EXCEL文件的实例

    一般的EXCEL导出使用POI先创建一个HSSFWorkbook,然后通过不断创建HSSFRow,HSSFCell后设置单元格内容便可以完成导出. 这次在项目中需要用到模板,导出的内容包括(1.模板中 ...

  8. 【Apache POI】Java Web根据模板导出word文件

    最近工作中遇到一个需求:根据word模板文档导出word文件. 查阅了一些资料,发现Apache POI可以实现文档读写的功能,于是就研究了一下,总结如下: Apache-POI在线Javadoc:h ...

  9. 图片复制word java_java poi实现word导出(包括word模板的使用、复制表格、复制行、插入图片的使用)...

    java poi实现数据的word导出(包括word模板的使用.复制表格.复制行.插入图片的使用) 1.实现的效果 实现病人基本信息.多条病历数据.多项检查项图片的动态插入(网络图片) 2.模板 把w ...

  10. springboot+poi开发excel导出 加载Excel模板导出 Excel批量导出详解

    提到Excel导出功能,可能很多人都使用springmvc框架做过,笔者今天要给大家分享的是基于springBoot开发Excel复杂模板导出功能(所谓复杂模板指在模板里的特定表头里有不同的单元格合并 ...

最新文章

  1. ASP.NET 如何动态修改 title Meta link标签
  2. MySQL 数据格式化
  3. 在64位系统上注册并使用32位的COM组件
  4. 【APICloud系列|24】 MNNavigationMenu模块(导航菜单)的实现
  5. web service 学习 2 -- 什么时候应该使用web service
  6. 深入阅读Mina源码(3) —— Mina之IOAdapter(二)
  7. Elasticsearch 安装随笔
  8. MVC 19个通信(请求)管道
  9. MySQL用什么输入法_最好用的输入法是什么?
  10. mysql 仓储系统规划与设计,仓库管理系统的设计与实现.doc
  11. 算法与数据结构全阶班-左程云版系列目录
  12. [转载]论原著中白飞飞和朱七七两大奇女子
  13. 如何批量下载央视CNTV的节目视频
  14. [ARCGIS]带黑边的IMG格式影像如何消除黑边?
  15. c51实现老人跌倒,心率异常报警系统
  16. Robocup新手指南
  17. 管理学生营养餐很重要
  18. JS- 数字自增动画
  19. python分析股票数据 彤_Python数据分析:股票数据
  20. asp 和 html 婚鞋,几招教会你搭配出完美婚鞋

热门文章

  1. Office文档背景变成黑色 - 解决方案
  2. 华为OD机试 - 新员工座位安排系统(Python) | 机试题算法思路
  3. input type=number maxlength无效
  4. 奥比中光Astra Pro Demo示例
  5. 解决wsappx占cpu和内存过大问题
  6. 增鑫科技更新招股书,冲刺深交所上市,正邦集团是其主要股东
  7. 细雨算法:B2B的配图图片是否可留联系方式,占比应为多大?
  8. 详解RocketMQ中的Producer
  9. 高通骁龙wear4100怎么样 相当于骁龙多少
  10. 优炫软件斩获“创客北京2022”海淀赛区二等奖