Y
Y
Yuriy2019-09-16 14:28:10
phpspreadsheet
Yuriy, 2019-09-16 14:28:10

PhpSpreadsheet won't load images inserted into Excel?

UDP.1 In general, I found out such a thing, if you put a picture with 32Bit, then everything is fine, there are no errors, as soon as the picture is 24Bit, everything breaks ...
When you open the formed excel, a window pops up
5d7f6fdb2f43f761939139.png
inside the broken picture, half of it did not load ...
5d7f70135ad1a724695935.png
what problem? Everything is fine on another hosting, Php7.1+ version, GD 2+
is installed via composer latest updates
{
"require": {
"phpoffice/phpspreadsheet": "^1.9"
}
}

$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
        if(file_exists($_SERVER["DOCUMENT_ROOT"].$product['PRODUCT_INFO']["DETAIL_PICTURE"]['SRC'])&&$product['PRODUCT_INFO']["DETAIL_PICTURE"]){
            $drawing->setPath($_SERVER["DOCUMENT_ROOT"].$product['PRODUCT_INFO']["DETAIL_PICTURE"]['SRC']);
        }else{
            $drawing->setPath($_SERVER["DOCUMENT_ROOT"].'/upload/no_photo_medium.png');
        }

        $drawing->setName('Image'.$tableLine);
        $drawing->setDescription('Image'.$tableLine);
        $drawing->setHeight(75);
        $drawing->setCoordinates('A'.$tableLine);
        $drawing->setOffsetX((105-$drawing->getWidth())/2);
        $drawing->setOffsetY(2);
        $drawing->setWorksheet($activeSheet);

        $tableLine++;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question