<?php

require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Cell\Cell;

$spreadsheet = new Spreadsheet();
$activeWorksheet = $spreadsheet->getActiveSheet();
$activeWorksheet->setCellValue('A1', 'Hello World !');
$activeWorksheet->setCellValue('A2', 2);
$activeWorksheet->setCellValue('A3', 3);
$activeWorksheet->setCellValue('A4', 4);

$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
$drawing->setWorksheet($spreadsheet->getActiveSheet());
$drawing->setPath('logo.png');
$drawing->setWidthAndHeight(158, 72);
$drawing->setResizeProportional(true);

$drawing->setOffsetX(100);    // this is how
$drawing->setOffsetY(30);    //

$formula1 = "=SUM(A2:A4)";

$activeWorksheet->setCellValue('A5', $formula1);

$writer = new Xlsx($spreadsheet);
$writer->save('hello world.xlsx');
ob_clean();
//print_r($writer);
