1. Go to this page and download the library: Download ang3/php-excel-encoder 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/ */
ang3 / php-excel-encoder example snippets
ng3\Component\Serializer\Encoder\ExcelEncoder;
// Create the encoder with default context
$encoder = new ExcelEncoder($defaultContext = []);
// Create the encoder...
// Test data
$data = [
// Array by sheet
'My sheet' => [
// Array by rows
[
'bool' => false,
'int' => 1,
'float' => 1.618,
'string' => 'Hello',
'object' => new DateTime('2000-01-01 13:37:00'),
'array' => [
'bool' => true,
'int' => 3,
'float' => 3.14,
'string' => 'World',
'object' => new DateTime('2000-01-01 13:37:00'),
'array' => [
'again'
]
],
],
]
];
// Encode data with specific format
$xls = $encoder->encode($data, ExcelEncoder::XLSX);
// Put the content in a file with format extension for example
file_put_contents('my_excel_file.xlsx', $xls);