远程图片下载的本地临时目录
$temp_pic = $this->download(你的远程图片链接,'./Public/temp/export/');
$local_pic_path = './Public/excel/temp/export/'.$temp_pic;
if (file_exists($local_pic_path)) {
$img = new \PHPExcel_Worksheet_Drawing();
$img->setPath($local_pic_path);//写入图片路径
$img->setHeight(100);//写入图片高度
$img->setWidth(100);//写入图片宽度
$img->setOffsetX(105);//写入图片在指定格中的X坐标值
$img->setOffsetY(5);//写入图片在指定格中的Y坐标值
$img->setRotation(1);//设置旋转角度
$img->getShadow()->setVisible(true);
$img->getShadow()->setDirection(50);
$img->setCoordinates('C1');//设置图片所在表格位置
$img->setWorksheet($objPHPExcel->getActiveSheet());//把图片写到当前的表格中
}
private function download($url, $path = 'images/')
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 信任任何证书
$file = curl_exec($ch);
curl_close($ch);
$filename = pathinfo($url, PATHINFO_BASENAME);
$resource = fopen($path . $filename, 'a');
fwrite($resource, $file);
fclose($resource);
return $filename;
}
不知道你是不是要这个