jeecgboot / autopoi

AutoPOI 功能如同名字auto,追求的就是自动化,让一个没接触过poi的人员,可以傻瓜化的快速实现Excel导入导出、Word模板导出、可以仅仅5行代码就可以完成Excel的导入导出。
http://www.jeecg.com
Apache License 2.0
460 stars 199 forks source link

大批数据导出报错问题 #89

Open wumangeng opened 1 year ago

wumangeng commented 1 year ago

我使用的版本是1.4.6,当导出数据达到500行时报错:Attempting to write a row[1567] in the range [0,1567] that is already written to disk. 导出代码为: List dataList = bareService.queryList(new BareSearchDTO());

        Workbook workbook = null;
        List<BareVO> bareVOList = new ArrayList<>(100);
        for (int i = 0; i < dataList.size(); i++) {
            System.out.print(i+",");
            bareVOList.add(dataList.get(i));
            if (bareVOList.size() == 100){
                workbook = ExcelExportUtil.exportBigExcel(new ExportParams(), BareVO.class, new IExcelExportServer() {
                    @Override
                    public List<Object> selectListForExcelExport(Object o, int i) {
                        if (((int) o) < i) {return null;}
                        System.err.println("obj -- "+ o +"   page -- "+ i);
                        return new ArrayList<Object>(bareVOList);
                    }
                },  1);
                bareVOList.clear();
            }
        }
        FileOutputStream fos = new FileOutputStream("D:/download/test_excel.xls");
        workbook.write(fos);
        fos.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

当i为500时报错

wumangeng commented 1 year ago

结合文档的例子测试,可以得出,导出的实体只要含有@ExcelCollection就会造成无法导出,例如下面的代码,将注释部分打开就无法导出: workbook = ExcelExportUtil.exportBigExcel(new ExportParams(), TestEntity.class, new IExcelExportServer() { /**