I have a complex excel which I managed to build using FromView interface. I had to use FromView because I have to manage different rowspans but the problem is that it goes on Maximum execution time of 60 seconds exceeded error for more then 500+ rows and it needs like 15 sec for just 100 rows.
Link with how I implemented the export: https://ibb.co/9VcZKDj
The data of the model I'm returning has 5 related tables (hasOne) which are being mapped on the final excel also.
Inside the view I make different foreach in order to map data as required. Link with image of the view: https://ibb.co/k8WG2jm
Link with image of a part of the excel I have generated for 100 rows: https://ibb.co/NpzC9yq
Any idea on how to achieve this. Thank you!
P.S. I'm not considering using a queue job because the rows at their max will be 2000.
I did managed without using FromView
but using WithMapping
and WithEvents
in which I did hard coded the customization of the cells with PhpSpreadsheet
helpers and it takes like 1.7-1.8 sec for 2000 rows.
What I do is merging the cells and setting the value like this:
$sheet->mergeCells('B'.$startingKey.':B'.$endingKey);
$sheet->setCellValue('B'.$startingKey, $participant->agency->corporation);