0
我使用PHPExcel Reader函數將excel文件轉換爲HTML表格。PHPExcel內存錯誤
我得到這個錯誤:致命錯誤:內存(分配1827405824)(試圖分配106個字節)
我已經改變了我對memory_limit的2048M在我的php.ini文件..
仍然收到錯誤..
那麼我怎樣才能只加載我的Excel文件的第一張,它也許可以解決我的問題?
$excel = glob(''.$test.'\\'.$client.'.{xlsx,xls,xlsm,xlsm.ink}',GLOB_BRACE);
$filterSubset = new \PHPExcel_Reader_DefaultReadFilter('A','N');
$objReader = \PHPExcel_IOFactory::createReaderForFile($excel[0]);
$objReader->setReadFilter($filterSubset);
$objPHPExcel = $objReader->load($excel[0]);
## THIS DOESNT WORK ?! ##
$objPHPExcel->setActiveSheetIndex(1);
$links = $objPHPExcel->getActiveSheet()->getHyperlinkCollection();
var_dump($links);
foreach ($links as $link){
$url = $link->getUrl();
$url = str_replace('file','mnt', $url);
$link->setUrl($url);
}
$writer = \PHPExcel_IOFactory::createWriter($objPHPExcel, "HTML");
$writer->generateStyles();
$writer->generateSheetData();
編輯:
我那樣做:
public function showClientAction($client)
{
$excel = glob(''.$path'.{xlsx,xls,xlsm,xlsm.ink}', GLOB_BRACE);
$filterSubset = new \PHPExcel_Reader_DefaultReadFilter('A','N');
$objReader = \PHPExcel_IOFactory::createReaderForFile($excel[0]);
$objReader->setReadFilter($filterSubset);
$worksheetList = $objReader->listWorksheetNames($excel[0]);
$sheetname = $worksheetList[0];
/** Advise the Reader of which WorkSheets we want to load **/
$objReader->setLoadSheetsOnly($sheetname);
$objPHPExcel = $objReader->load($excel[0]);
var_dump($sheetname);
$writer = \PHPExcel_IOFactory::createWriter($objPHPExcel, "HTML");
$writer->generateStyles();
$writer->generateSheetData();
return $this->render('MonextPerfclientBundle:Default:testexcel.html.twig', array(
'excelHtml'=>$writer,
'stylesExcel'=>$writer,
));
}
的var_dump($sheetname);
輸出是很好的,它的偉大工程!
但我怎麼能確定只加載第一張?
它不似乎是一個更快的加載.. * scuze我的英語..
是否可以加載和顯示我的Excel文件中的過濾器,並通過HTML表格將其轉換爲下拉按鈕? –