Skip to content

Instantly share code, notes, and snippets.

@bsevgin
Forked from outman/export_image_to_excel
Created February 28, 2018 12:13
Show Gist options
  • Save bsevgin/adb83767d24e425174ab1325dc76832c to your computer and use it in GitHub Desktop.
Save bsevgin/adb83767d24e425174ab1325dc76832c to your computer and use it in GitHub Desktop.
Exprot Online Image to Excel by PHPExcel
<?php
require_once __DIR__ . '/PHPExcel/Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
// imagecreatefromXXX (XXX is jpeg png or gif)
$gdImage = imagecreatefromjpeg('http://678bt.com/PHPExcel/Tests/images/officelogo.jpg');
$objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
$objDrawing->setName('Sample image');
$objDrawing->setDescription('Sample image');
$objDrawing->setImageResource($gdImage);
$objDrawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
$objDrawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT);
$objDrawing->setHeight(36);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment