phpexcel 导出超过50000数据失败

1.设置对象缓存策略
有好几种根据需求选择不同的策略

  $cacheMethod = \PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip;
        if (!\PHPExcel_Settings::setCacheStorageMethod($cacheMethod)) {
            die($cacheMethod . " caching method is not available" . EOL);
        }

2.避免在添加数据时候添加不必要操作

之前循环里面包含了设置居中的代码,两层循环执行的次数非常长,不合算。

 foreach ($data as $k => $v) {
            foreach ($headerArr as $k1 => $v1) {
                $val = $v[$k1] . '';
                $objSheet->setCellValue($headCharArr[$k1] . $j, $val);
            }
            $j++;
        }

你可能感兴趣的:(phpexcel 导出超过50000数据失败)