PHPExcel 允许耗尽的内存大小
PHPExcel Allowed memory size of exhausted
我正在创建带有图像的大 excel 文件,现在我遇到了这个问题。没有图像一切正常。
除此之外,我无法增加内存限制。
我该怎么办?
我找不到真正的代码示例,我听说过 reader 但我不明白如何正确使用它。
foreach ($array as $key => $value) {
$sheet->setCellValue("A".$i, $value['articul']);
$sheet->setCellValue("B".$i, $value['text']);
//uploading image to my server
$type_img = explode( ".",$value['image']);
$type_img = ".".end($type_img);
$pht_lnk = $value['image'];
$photoname = explode("/", $value['image']);
$photoname = end($photoname);
$dir_upl = 'img/'.$photoname;
if (!fileExists($dir_upl)) {
if(file_put_contents($dir_upl, file_get_contents($pht_lnk))) {
$imagePath = $dir_upl;
}
else{
$imagePath = NULL;
}
}
else{
$imagePath = $dir_upl;
}
//here i'm trying to add image
if (file_exists($imagePath)) {
$imgg = new PHPExcel_Worksheet_Drawing();
$imgg->setPath($imagePath);
$imgg->setCoordinates("C".$i);
$imgg->setOffsetX(0);
$imgg->setOffsetY(0);
$sheet->getRowDimension(2)->setRowHeight(190);
$imgg->setWorksheet($sheet);
}
$sheet->setCellValue("D".$i, $value['price']);
$i++;
}
如果你不能增加内存限制尝试另一个库
PHP-Export-Data 伊莱·狄金森
我正在创建带有图像的大 excel 文件,现在我遇到了这个问题。没有图像一切正常。 除此之外,我无法增加内存限制。
我该怎么办? 我找不到真正的代码示例,我听说过 reader 但我不明白如何正确使用它。
foreach ($array as $key => $value) {
$sheet->setCellValue("A".$i, $value['articul']);
$sheet->setCellValue("B".$i, $value['text']);
//uploading image to my server
$type_img = explode( ".",$value['image']);
$type_img = ".".end($type_img);
$pht_lnk = $value['image'];
$photoname = explode("/", $value['image']);
$photoname = end($photoname);
$dir_upl = 'img/'.$photoname;
if (!fileExists($dir_upl)) {
if(file_put_contents($dir_upl, file_get_contents($pht_lnk))) {
$imagePath = $dir_upl;
}
else{
$imagePath = NULL;
}
}
else{
$imagePath = $dir_upl;
}
//here i'm trying to add image
if (file_exists($imagePath)) {
$imgg = new PHPExcel_Worksheet_Drawing();
$imgg->setPath($imagePath);
$imgg->setCoordinates("C".$i);
$imgg->setOffsetX(0);
$imgg->setOffsetY(0);
$sheet->getRowDimension(2)->setRowHeight(190);
$imgg->setWorksheet($sheet);
}
$sheet->setCellValue("D".$i, $value['price']);
$i++;
}
如果你不能增加内存限制尝试另一个库
PHP-Export-Data 伊莱·狄金森