PHPSpreadsheet - How do i place a image from link into my excel file?

$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing();
                    $drawing->setImageResource(imagecreatefrompng('https://pngimage.net/wp-content/uploads/2018/06/rfhnbyrb-png-6.png');
                    $drawing->setCoordinates($cell->getCoordinate());
                    $drawing->setWidthAndHeight(50, 50);
                    $drawing->setRenderingFunction(\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::RENDERING_JPEG);
                    $drawing->setMimeType(\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::MIMETYPE_DEFAULT);
                    $drawing->setOffsetX(110);
                    $drawing->setRotation(25);
                    $drawing->getShadow()->setVisible(true);
                    $drawing->getShadow()->setDirection(45);
                    $drawing->setWorksheet($csv->getActiveSheet());

I am using phpspreedsheet in PHP 7.2 with latest phpspreedsheet version.

<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing;

$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();

$IMG = 'https://pngimage.net/wp-content/uploads/2018/06/rfhnbyrb-png-6.png';
$row_num = 2;
if (isset($IMG) && !empty($IMG)) {
    $imageType = "png";

    if (strpos($IMG, ".png") === false) {
        $imageType = "jpg";
    }

    $drawing = new MemoryDrawing();
    $sheet->getRowDimension($row_num)->setRowHeight(80);
    $sheet->mergeCells('A'.$row_num.':H'.$row_num);

    $gdImage = ($imageType == 'png') ? imagecreatefrompng($IMG) : imagecreatefromjpeg($IMG);
    $drawing->setName('Company Logo');
    $drawing->setDescription('Company Logo image');
    $drawing->setResizeProportional(false);
    $drawing->setImageResource($gdImage);
    $drawing->setRenderingFunction(\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::RENDERING_JPEG);
    $drawing->setMimeType(\PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing::MIMETYPE_DEFAULT);
    $drawing->setWidth(211);
    $drawing->setHeight(40);
    $drawing->setOffsetX(5);
    $drawing->setOffsetY(30);
    $drawing->setCoordinates('C'.$row_num);
    $drawing->setWorksheet($spreadsheet->getActiveSheet());
    $row_num++;
}

$writer = new Xlsx($spreadsheet);
$writer->save('hello world.xlsx');

I got a solution for you. But unfortunately i couldn't find a way to use a url but an image localy. take a look.

require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();

$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
$drawing->setName('Paid');
$drawing->setDescription('Paid');
$drawing->setPath('images/paid.png'); // put your path and image here
$drawing->setCoordinates('B15');
$drawing->setOffsetX(110);
$drawing->setRotation(25);
$drawing->getShadow()->setVisible(true);
$drawing->getShadow()->setDirection(45);
$drawing->setWorksheet($spreadsheet->getActiveSheet());

$writer = new Xlsx($spreadsheet);
$writer->save('image.xlsx');

It's working just fine, enjoy :)

enter image description here

enter image description here