fast-excel
fast-excel copied to clipboard
SheetCollection issue
Is it possible to build SheetCollection with a function return like you can with the base export option? Or is there better example of using the SheetCollection?
Hi, thank you for contributing! I don't really understand your question. What do you want to do? Could you please give an example?
My apologies for being a little vague.
So currently I use FastExcel like this.
(new FastExcel($data))->export(storage_path('file.xlsx'), function ($data) {
return [
'A' => $data->content_a,
'B' => $data->content_b,
'C' => $data->content_c,
];
});
Which works perfectly on single sheet excel files.
I was wondering if it was possible to use the SheetCollection in a similar manner, such as:
$sheets = new SheetCollection([
'Users' => function ($dataA) {
return [
'A1' => $dataA->content_a,
'A2' => $dataA->content_b,
'A3' => $dataA->content_c,
];
},
'Second sheet' => function ($dataB) {
return [
'B1' => $dataB->content_a,
'B2' => $dataB->content_b,
'B3' => $dataB->content_c,
];
},
]);
(new FastExcel($sheets))->export('file.xlsx');
I ask the same question
It is now possible, source: https://github.com/rap2hpoutre/fast-excel#export-multiple-sheets