Open Faryshta opened 9 years ago
Thanks @Faryshta This save me a lot of testing hours...
I use Laravel, and the same doc was download in xls or pdf. For xls the image inclusion must have the full path, but for pdf export, the image must have the public path.
So, I use this, and work fine for me.
// $file is an array with data to export XLS or PDF
// $image was defined from one Laravel Model ($model->image)
$image = ($file['ext'] == 'pdf') ? $image : base_path() . $image
$logo = new PHPExcel_Worksheet_Drawing();
$logo->setName('Logo')
->setDescription('Logo')
->setPath($image, false)
Thanks and sorry my English.
the pdf example doesn't include how to add an image to the generated file.
On the example the library used is mPDF which has a different approach on how to include images.
While phpexcel uses the file:// protocol to load an image and check if it exists, mPDF uses http:// by default to load an image.
On Excel 5 the way to include an image is
Yet that will generate an image on html like
Which obviously won't load.
The solution i found is
and the
false
part is vital because without that phpExcel will check if the file exists and won't find it sending an exception.I think its important to add that to the example because i couldn't find anything related to this issue.