qq_44681001 2019-06-15 10:51 采纳率: 0%
浏览 891

关于execel 出现 unable to read entire header的问题 求各位大神分析一下 哪里出错了!!!!

图片说明

 public static Workbook fillExcelDataWithTemplate(List<StatisticsDTO> list ,String templateFileUrl) {
        Workbook wb = null ;
        try {
            File file  = new File(templateFileUrl);
            if(!file.exists()){
                file.createNewFile();
            }
            POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(file));
            wb = new HSSFWorkbook(fs);
            // 取得 模板的 第一个sheet 页
            Sheet sheet = wb.getSheetAt(0);
            // 拿到sheet页有 多少列
            int cellNums = sheet.getRow(0).getLastCellNum();
            // 从第2行 开搞    下标1  就是第2行
            int rowIndex = 1;
            Row row ;
            for(StatisticsDTO statisticsDTO : list){
                row = sheet.createRow(rowIndex);
                rowIndex ++;
                row.createCell( 0).setCellValue(statisticsDTO.getId());
                row.createCell(1).setCellValue(statisticsDTO.getNewUserCount());
                row.createCell(2).setCellValue(statisticsDTO.getTotalPayCount());
                row.createCell(3).setCellValue(statisticsDTO.getTotalPayNum());
                row.createCell(4).setCellValue(statisticsDTO.getWeixinpayPayCount());
                row.createCell(5).setCellValue(statisticsDTO.getWeixinpayPayNum());
                row.createCell(6).setCellValue(statisticsDTO.getAlipayPayCount());
                row.createCell(7).setCellValue(statisticsDTO.getAlipayPayNum());
                row.createCell(8).setCellValue(statisticsDTO.getDggPayCount());
                row.createCell(9).setCellValue(statisticsDTO.getDggPayNum());
                row.createCell(10).setCellValue(DateUtil.formatDate(statisticsDTO.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return wb;
    }
  • 写回答

2条回答 默认 最新

  • threenewbee 2019-06-15 11:04
    关注

    格式不兼容,文件损坏,或者把xlsx误当作xls了

    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧