laravel excel export image failed

Viewed 118

I'm currently using the Laravel Excel plugin for exporting my files in .xls format. but when I open the excel file and I found out that I was not exporting the actual file but exporting the path(for the signature column).. image for .xls file. This is the link I used for reference: https://docs.laravel-excel.com/3.1/imports/model.html

this is the expected exported file image for image saved folder

here is my code:

1.For the export.php

<?php

namespace App\Exports;

use App\Models\signature;
use Maatwebsite\Excel\Concerns\FromCollection;

//frow laravel excel  drawing(image export) 
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
use Maatwebsite\Excel\Concerns\WithHeadings;

use Maatwebsite\Excel\Concerns\WithColumnWidths;





class SignatureExport implements FromCollection,  WithHeadings, WithColumnWidths
{
    /**
    * @return \Illuminate\Support\Collection
    */
    public function collection()
    {
        return signature::all();
    }


    public function drawings()
    {
        $drawing = new Drawing();
        $drawing->setName('signature');
        $drawing->setDescription('This is my signatuer');
        $drawing->setPath(public_path('/uploads/signatures'));
        $drawing->setHeight(90);
        $drawing->setCoordinates('B3');

        return $drawing;
    }

    public function headings(): array
    {
        return [
            'id',
            'name',
            'description',
            'signature',
            'created_at',
            'updated_at',
        ];
    }

    public function columnWidths(): array
{
    return [
        'A' => 30,
        'B' => 30,        
        'C' => 30,
        'D' => 30,    
        'E' => 30,          
    ];
}


}

2.Controller code:

    //for export in excel

    public function exportexcel()
    {
        return Excel::download(new SignatureExport, 'signaturelist.xlsx');

    }

What did I miss Sorry I am new to programming, and any answers are appreciated.

PS. I'm also looking on how to import excel data in my situation , hope for sharing tutorials or links . Thank you

0 Answers
Related