0

I'm using Laravel Excel to dump a number of records to XLS format.

Each of my records has an image_url field that contains a remote URL to a JPG file.

I'd like to display these images in the final XLS file, in their own column.

I tried creating a Blade template for the export, but when using <img> tags, the images don't appear in the XLS file. I'm not getting any errors, and the documentation for Laravel Excel is very sparse when it comes to image integration.

So what would be the easiest way to get the images to display in the XLS, using Laravel Excel? Is there some way I can get the Blade template to work, or must I add the images more programmatically?

phildi
  • 21
  • 2

1 Answers1

-1

something like this should work, you gotta load the PHPExcel_Worksheet_Drawing library.

$filename = 'File Name';

Excel::create($filename, function($excel) {
   $excel->sheet('sheet name', function($sheet) {
        $objDrawing = new PHPExcel_Worksheet_Drawing;
        $objDrawing->setPath(public_path('your/image/path.jpg')); //your public image path
        $objDrawing->setPath(storage_path('your/image/path.jpg')); //your storage image path
        $objDrawing->setCoordinates('A2');
        $objDrawing->setWorksheet($sheet);
   });
})->export('xls');
Barry
  • 3,303
  • 7
  • 23
  • 42
Erubiel
  • 2,934
  • 14
  • 32