1. Go to this page and download the library: Download lab36/excel-report 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/ */
lab36 / excel-report example snippets
namespace App\ExcelReport;
use Lab36\ExcelReport\ExcelReport;
class ProjectDetailsExcelReport extends ExcelReport
{
public function columnMappings(): array
{
return [
'project' => 'Project name',
'start_date' => 'Project date',
'cost' => 'Cost',
'type' => 'Type',
'state'=> 'State',
'client_name'=>'Client name',
'client_address'=>'Client address',
];
}
}
public function overrideCell(Worksheet $active_sheet, int $current_row_no, int $column_no, $value, array $row_data, string $column_name)
{
if ($column_name == 'order_type' && is_numeric($value)) {
$active_sheet->setCellValue(Coordinate::stringFromColumnIndex($column_no).$current_row_no,
config('enums.order_type')[$value]);
}
}