使用phpexcel将xls文件作为多维数组读取

时间:2018-03-24 14:11:12

标签: php cakephp phpexcel

我想在PHP中将此xls文件检索为数组:

enter image description here

我试过这段代码:

App::import('Vendor', 'PHPExcel', array('file' => 'PHPExcel.php'));
$excelFile = DAY_DIR."/data.xlsx";

$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load($excelFile);

//Itrating through all the sheets in the excel workbook and storing the array data
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
    $arrayData[$worksheet->getTitle()] = $worksheet->toArray();
}

pr($arrayData);

我想将它作为多维数组读取,但它返回: enter image description here

请建议我如何实现它。

0 个答案:

没有答案