I am trying to insert an image in the center of the first cell. A cell is a merge of four cells:
$phpExcel->getActiveSheet()->mergeCells('A1:D1');
$phpExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(65);
I followed the instructions from this to center the image.
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Sima');
$objDrawing->setDescription('Logo');
$objDrawing->setPath('../img/logo.jpg');
$objDrawing->setOffsetX(300);
$objDrawing->setCoordinates('A1');
$objDrawing->setHeight(80);
$objDrawing->setWorksheet($phpExcel->getActiveSheet());
and then save and upload the file
$writer = PHPExcel_IOFactory::createWriter($phpExcel, "Excel2007");
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="test.xlsx"');
header('Cache-Control: max-age=0');
ob_end_clean();
$writer->save('php://output');
If I open the generated file using LibreOffice, I can see the image in the center, but if I open it using Ms Excel 2010, the image is aligned to the left.
Any idea ???
source
share