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

    xiaoxiao2021-03-25  77

    通过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模板文件打开失败");                 }

    转载请注明原文地址: https://ju.6miu.com/read-38160.html

    最新回复(0)