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 如何实验stm32主通道和互补通道独立输出
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题