Encontramos el resultado a esta incógnita, o por lo menos eso deseamos. Si sigues con inquietudes coméntalo, que sin dudarlo te responderemos
Solución:
Tengo una solución para ti. Pero desafortunadamente no pude encontrar una manera de usar una URL sino una imagen localmente. echar un vistazo.
require 'vendor/autoload.php';
use PhpOfficePhpSpreadsheetSpreadsheet;
use PhpOfficePhpSpreadsheetWriterXlsx;
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$drawing = new PhpOfficePhpSpreadsheetWorksheetDrawing();
$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');
Está funcionando bien, disfrútalo 🙂
$drawing = new PhpOfficePhpSpreadsheetWorksheetMemoryDrawing();
$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(PhpOfficePhpSpreadsheetWorksheetMemoryDrawing::RENDERING_JPEG);
$drawing->setMimeType(PhpOfficePhpSpreadsheetWorksheetMemoryDrawing::MIMETYPE_DEFAULT);
$drawing->setOffsetX(110);
$drawing->setRotation(25);
$drawing->getShadow()->setVisible(true);
$drawing->getShadow()->setDirection(45);
$drawing->setWorksheet($csv->getActiveSheet());
Estoy usando phpspreedsheet en PHP 7.2 con la última versión de phpspreedsheet.
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(PhpOfficePhpSpreadsheetWorksheetMemoryDrawing::RENDERING_JPEG);
$drawing->setMimeType(PhpOfficePhpSpreadsheetWorksheetMemoryDrawing::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');
Tienes la posibilidad dar visibilidad a este artículo si te valió la pena.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)