POI生成excel数据量大时内存溢出解决

来源:互联网 发布:趣味性软件使用教程 编辑:程序博客网 时间:2024/05/01 18:15

通过SXSSFWorkbook替换XSSFWorkbook



                File file = new File(Constants.WEB_ROOT
                        + "templet/price.xlsx");
                if (!file.exists()) {
                    throw new RuntimeException("excel模板文件不存在");
                }

                Workbook workbook = null;
                try {
                    XSSFWorkbook xssworkbook = new XSSFWorkbook(
                            new FileInputStream(file));
                    workbook = new SXSSFWorkbook(xssworkbook, 10000);
                } catch (Exception e) {
                    throw new RuntimeException("excel模板文件打开失败");
                }

0 0