user3553866
user3553866

Reputation: 326

inserted pictures in wrong sheet (last in place first) PHPEXCEL

I create a xlsx file :

$objPHPExcel = new PHPExcel();
$sheet = $objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex($i);

I put a picture into a cell with this code :

$objDrawing = new PHPExcel_Worksheet_Drawing();
           $objDrawing->setName('logo PHARMA');
           $objDrawing->setDescription('logo PHARMA');
           $objDrawing->setPath('../../images/pharma.png');
           $objDrawing->setHeight(136);
           $objDrawing->setCoordinates('B1');
           $objDrawing->setOffsetX(-10);
           $objDrawing->setWorksheet($sheet);

Inside the first sheet, I have no picture, but in the last sheet (where I have no informaiton, I do not need this last sheet), I have pictures.

I have a problem a interval.

Upvotes: 1

Views: 58

Answers (1)

Waqas Ahmed
Waqas Ahmed

Reputation: 98

According to the documentation when you create a new sheet, "By default, this will be created as a new last sheet" so the following line will insert a new sheet at the end.

$sheet = $objPHPExcel->createSheet();

A possible solution I think would be to change the last line to this

$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());

Upvotes: 2

Related Questions