fast-excel icon indicating copy to clipboard operation
fast-excel copied to clipboard

SheetCollection issue

Open dbenn-marco opened this issue 5 years ago • 3 comments

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?

dbenn-marco avatar Aug 27 '19 20:08 dbenn-marco

Hi, thank you for contributing! I don't really understand your question. What do you want to do? Could you please give an example?

rap2hpoutre avatar Aug 29 '19 12:08 rap2hpoutre

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');

dbenn-marco avatar Aug 30 '19 13:08 dbenn-marco

I ask the same question

TiagoKnow avatar Apr 13 '20 18:04 TiagoKnow

It is now possible, source: https://github.com/rap2hpoutre/fast-excel#export-multiple-sheets

rap2hpoutre avatar Sep 01 '23 06:09 rap2hpoutre