Yii PHPExcel组件导入wps编辑过的或者wps生成的excel文件内存溢出问题

用文件流的的方式来解决

            try {
                $objReader = \PHPExcel_IOFactory::createReader('Excel2007');
                $objReader->setReadDataOnly(true);
                $objPHPExcel = $objReader->load("2018.xlsx");
                $objWorksheet = $objPHPExcel->getActiveSheet();
                $data = [];
                foreach ($objWorksheet->getRowIterator() as $row) {
                    $temp = [];
                    $cellIterator = $row->getCellIterator();
                    $cellIterator->setIterateOnlyExistingCells(false);
                    foreach ($cellIterator as $cell) {
                        $temp[] = $cell->getValue();
                    }
                    array_push($data, $temp);
                }
                var_dump($data);
            }catch (\Exception $e){
                echo $e->getMessage();
            }

 

你可能感兴趣的:(Yii,php技术)