rap2hpoutre / fast-excel

🦉 Fast Excel import/export for Laravel
MIT License
2.08k stars 246 forks source link

How to have multiple sheets and also give specific column names to the same? #344

Open SawantTejas opened 8 months ago

SawantTejas commented 8 months ago

I want to specify different column names for multiple sheets having different columns

Consider the following example where I have two sheets: Product Validity and ID Warranty. Now I want to specify different names for the fields of both sheets. How do I achieve that? Currently I am able to only mention Product Name and it applies to both sheets. I want to have a different name for the second sheet. I am unable to find any reference to achieve this so far

$sheets = new SheetCollection([
            'Product Validity' => $data1
            'ID Warranty' => $data2
        ]);
return (new FastExcel($sheets))->download('Export.xlsx', function($event){
            return [
                'Product Name' (ID Name) => $event->key, 
                'Product Validity' (ID Warranty) => $event->date, 
            ];
        });

Would appreciate any help or guidance for the same.