excel意思理解帮助

    @Override
    public void excelBusinessData(HttpServletResponse response) {
        //查询数据库获取营业数据
        List<Report> reportList = reportMapper.excelBusinessData();
        //通过poi将数据写入到excel文件中
        InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream("template/template.xlsx");

        //基于模版文件创建一个新的excel
        try {
            XSSFWorkbook excel = new XSSFWorkbook(resourceAsStream);
            //获取标签页
            XSSFSheet sheet1 = excel.getSheet("Sheet1");

            sheet1.getRow(1).getCell(1).setCellValue("我是第二行第二列");
            //获得第三行
            XSSFRow row = sheet1.getRow(2);
            row.getCell(0).setCellValue("我是第三行第一列");
            row.getCell(1).setCellValue("我是第三行第二列");
            row.getCell(2).setCellValue("我是第三行第三列");
            row.getCell(3).setCellValue("我是第三行第四列");


            //填充真实数据

            for (Report report : reportList) {

                //获得某一行
                row.getCell(7 );
                row.getCell(0).setCellValue(report.getFilName());
                row.getCell(1).setCellValue(report.getRepOrder());
                row.getCell(2).setCellValue(report.getRepPdfUrl());
                row.getCell(3).setCellValue(report.getStatus());
                row.getCell(4).setCellValue(report.getUserName());

            }

         /*   for (int i = 0; i < 30; i++) {
                //获得某一行
                row.getCell(7 + i);
                row.getCell(0).setCellValue(report.getFilName());
            }
            */

            //通过输出流将excel文件下载到客户端的浏览器
            ServletOutputStream outputStream = response.getOutputStream();
            excel.write(outputStream);
            outputStream.close();

        } catch (IOException e) {
            throw new RuntimeException(e);
        }




    }
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值