php - 如何使用 phpexcel 库在 excel 中嵌入(插入对象)文档?
问题描述
我可以使用 MS Excel手动嵌入文档(插入 -> 对象 -> 从文件创建) 。请参考图片。
如何通过 PHPExcel 或任何其他 PHP 库来实现这一点?
解决方案
首先,你应该使用phpspreadsheet,phpexcel已经被它取代了。我在我的 phpspreadsheet 安装的子目录 /templates/sampleSpreadsheet.php 中找到了这段代码。您可能会在 phpexcel 安装中找到它?
// Add a drawing to the worksheet
$helper->log('Add a drawing to the worksheet');
$drawing = new Drawing();
$drawing->setName('PhpSpreadsheet logo');
$drawing->setDescription('PhpSpreadsheet logo');
$drawing->setPath(__DIR__ . '/images/PhpSpreadsheet_logo.png');
$drawing->setHeight(36);
$drawing->setCoordinates('D24');
$drawing->setOffsetX(10);
$drawing->setWorksheet($spreadsheet->getActiveSheet());
推荐阅读
- google-cloud-dataproc - 有没有办法更改 dataproc 作业的驱动程序日志输出的位置?
- tensorflow - Golang 上的 TensorFlow 部分运行(RNN 状态)
- typescript - 从交叉路口类型中选择?(TS)
- python - 如何将列表插入到 CSV 文件的列中
- image - 计时器完成后加载图像
- sql - Postresql SQL 状态:25P02 死锁?
- docker - Kubernetes 在主节点和节点中是否支持不同的 Docker 版本?
- c# - 加载和保存 RTF FlowDocument
- sharepoint - 使用表达式生成器将新行/crlf 包含到字符串变量中
- db2 - 查询 Db2 - 更正两个没有结果的表