php - 使用 phpspreedsheet 将图像链接到单元格
问题描述
我正在使用此代码在列和单元格中添加图像。
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($img);
imagecopyresampled($image_p, $image, 0, 0 , 0 , 0, $width, $height, $width_orig, $height_orig);
$draw->setName($itmref[$key]);
$draw->setResizeProportional(false);
$draw->setImageResource($image_p);
$draw->setRenderingFunction(\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::RENDERING_JPEG);
$draw->setMimeType(\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::MIMETYPE_DEFAULT);
$draw->setCoordinates('B'.$i);
$draw->setWorksheet($this->_spreadsheet->getActiveSheet());
问题是它们没有链接到单元格,因此如果用户过滤或排序 Excel 文件,图像将保留在其位置。
在 VBA 中,参数为:
Selection.Placement = xlMoveAndSize
但我在 PhpSpreedSheet 中找不到匹配项。
解决方案
推荐阅读
- sql-server - SQL Server 将表值函数的输入和输出类型与表值参数匹配
- java - 当相机平移时,精灵不会跟随 box2d 主体,但如果相机在 libgdx 中是静态的,则效果很好
- apache-kafka - Kafka 连接 mysql 自定义查询
- ms-access - 带有 unicode 字符的未绑定字段
- angular - 如何订阅 flatMap 的结果?
- aws-iot - 当设备在 aws iot 核心上未正常断开连接时如何检查事物的状态
- python - 使用 pip install -e 在 setup.py 中安装 data_files
- c++ - 如何初始化 std::map
键递增但值相同? - c# - datgridview 中的复选框在选中时不会刷新页面
- android - 在android登录活动的自动完成列表中显示名称而不是电子邮件