1. Go to this page and download the library: Download arodiss/xls-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$file = $container
->get("arodiss.xls.builder")
->buildXlsFromArray(array(
array("row one field one", "row one field two"),
array("row two field one")
))
;
//now $file is path to tmp file with data
$response = new Response();
$response->headers->set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
$response->headers->set("Content-Disposition", "attachment;filename=excelfile.xlsx");
$response->setContent(file_get_contents($file));
return $response;