Skip to content

Multiple Drawings = Damaged Excel File #1140

Closed
@TiToMoskito

Description

@TiToMoskito

This is:

  • a bug report

What is the expected behavior?

I need a Excel file with a few images on it.

What is the current behavior?

If i draw multiple images, the excel file could not be opened.

What are the steps to reproduce?

$mysql->query('SELECT * FROM fruits');
$fruits = $mysql->resultset();

$column = "A";
$nextRow = 0;
$titleRow = 7;
$picRow = 8;
$priceDRow = 9;
$priceRow = 10;
$remarkRow = 11;
for ($i=0; $i < sizeof($fruits); $i++) 
{        
    addImage(__DIR__ .'/upload/'.$fruits[$i]["Image"],$column.$picRow, 100, $spreadsheet->getActiveSheet());

    if($column == "A"){
        $column = "B";
    }else if($column == "B"){
        $column = "C";
    }else if($column == "C"){
        $column = "D";
    }else if($column == "D"){
        $titleRow += 5;
        $picRow += 5;
        $priceDRow += 5;
        $priceRow += 5;
        $remarkRow += 5;
        $column = "A";
    }
}

function addImage($path, $coordinates, $height, $sheet){
    $drawing = new Drawing();
    $drawing->setPath($path);
    $drawing->setHeight($height);
    $drawing->setCoordinates($coordinates);
    $drawing->setWorksheet($sheet);
}

Which versions of PhpSpreadsheet and PHP are affected?

Latest Version (1.8)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions