aVadim483 / fast-excel-reader

Lightwight and very fast XLSX Excel Spreadsheet Reader in PHP
MIT License
63 stars 16 forks source link

Add Image / drawing supports #6

Closed faustfizz closed 1 year ago

faustfizz commented 1 year ago

This library is so awesome and useful.

But I would like to have the ability to import images from xlsx files

You see, people use xlsx for customer registration, when you want to make an application for customer registration many do not accept because they think they can never migrate their data which seems logical.

With this tool, it is possible to migrate from xlsx to sql but what about images?

So I would like if possible to have this feature or someone to tell me how I can integrate it.

Thanks in advance

aVadim483 commented 1 year ago

Hi! I think I can do it in the new version

faustfizz commented 1 year ago

I'll be happy twice 😊 Thanks in advance

aVadim483 commented 1 year ago

https://github.com/aVadim483/fast-excel-reader#images-functions

faustfizz commented 1 year ago

https://github.com/aVadim483/fast-excel-reader#images-functions

@aVadim483 Thanks you! You are genius. I haven't tested it yet but I'll do it soon. When I use KEYS_FIRST_ROW, how to get image the current row (I didn't see it on readMe)? You are the best 👌

aVadim483 commented 1 year ago
$excel = Excel::open($file);
$sheet = $excel->sheet();
foreach ($sheet->nextRow() as $rowNum => $rowData) {
    // getImageListByRow() without argument returns images info from current row as array
    $imageList = $sheet->getImageListByRow();
    foreach ($imageList as $imageInfo) {
        // $imageInfo['address'] contains cell address of an image
        $imageBlob = $sheet->getImageBlob($imageInfo['address']);
    }
}