如何使用phpexcel库在Excel中嵌入(插入对象)文档?

时间:2019-01-25 06:03:33

标签: php phpexcel

我可以使用MS Excel手动嵌入文档(插入->对象->从文件创建)。请参考图片。

https://thewindowsclub-thewindowsclubco.netdna-ssl.com/wp-content/uploads/2016/08/select-format-option.png

如何通过PHPExcel或任何其他PHP库实现此目标?

1 个答案:

答案 0 :(得分:0)

首先,您应该使用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());