php - PHPExcel 允许的内存大小耗尽
问题描述
我正在创建带有图像的大 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++;
}
解决方案
推荐阅读
- c# - 使图像出现在前面
- python - 如何在 Python 中读取输入直到下一次出现
- sql - SQL - 删除空白/空行并合并行
- javascript - 该网站如何将所有内容隐藏在检查元素中?
- c# - 如何从 MySql 的表中获取 C# 中即将到来的约会?
- windows - 使用 ADO ODBC 上传到服务器时,在 VB.NET WEB APPLICATION 中打开与 MS Access DB 的连接时出错
- angular - 仅删除 mat-select 组件的 Scroll Webkit css 类
- go - cmd找不到文件
- css - jekyll 中的 CSS 覆盖
- typescript - 在 nestjs 中导入并注入 typeorm 存储库