1 Add to composer.json to the require key
composer require tanur/excel-bundleor manually in composer.json
...,
"require": {
...,
"tanur/excel-bundle": "~1.0"
},
...2 Symfony 3 : Register the bundle in app/AppKernel.php
$bundles = array(
// ...
new \Onurb\Bundle\ExcelBundle\OnurbExcelBundle(),
);Symfony 4 : With symfony flex, bundle should be already automatically registered :
// config/bundles.php
return [
// ...
Onurb\Bundle\ExcelBundle\OnurbExcelBundle::class => ['all' => true],
];$spreadsheet = $this->get('phpspreadsheet')->createSpreadsheet();$spreadsheet = $this->get('phpspreadsheet')->createSpreadsheet('file.xlsx');$writer = $this->get('phpspreadsheet')->createWriter($spreadsheet, 'Xls');
$writer->save('file.xls');$writer = $this->get('phpspreadsheet')->createWriter($spreadsheet, 'Xlsx');
$response = $this->get('phpspreadsheet')->createStreamedResponse($writer);$writer = $this->get('phpspreadsheet')->createSpreadSheet();
$writer->setActiveSheetIndex(0);
$activesheet = $writer->getActiveSheet();
$drawingobject = $this->get('phpspreadsheet')->createSpreadsheetWorksheetDrawing();
$drawingobject->setPath('/path/to/image')
->setName('Image name')
->setDescription('Image description')
->setHeight(60)
->setOffsetY(20)
->setCoordinates('A1')
->setWorksheet($activesheet);$reader = $this->get('phpspreadsheet')->createReader('Xlsx');Types are case sensitive. Supported types are:
Xlsx: Excel 2007Xls: Excel 5Xml: Excel 2003 XMLSlk: Symbolic Link (SYLK)Ods: Libre Office (ODS)Csv: CSVHtml: HTML
TcpdfMpdfDompdf
to install these libraries :
composer require tecnick.com/tcpdf
composer require mpdf/mpdf
composer require dompdf/dompdfFor users already using liuggio/ExcelBundle wanting to migrate to phpspreadsheet, the bundle should be directly compatible : old phpexcel file types are maintained, a compatibility factory has been added, and the phpexcel service is also redeclared.
See also the official PhpSpreadsheet documentation.

