GodziLaravel's avatar

Maatwebsite\Excel: impossible to download a file with 100 000 rows !

Hello

I try to return an excel file of more than 100 000 rows but it seems not possible ;

The sql request works very well and gives the results (with pagination)

But when I try to use Maatwebsite\Excel it gives me : 502 Bad Gateway

nginx errorLog:

2022/11/23 12:54:45 [error] 608722#608722: *60530 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.10.1, server: irplocal.com, request: "GET /api/people/planning?dateRange[]=2022-08-01T22:00:00.000Z&dateRange[]=2022-08-01T23:00:00.000Z&segmentId=505 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "irplocal.com"

So I : changed max_execution_time to 600

make memory_limit = -1

Added also :

public function chunkSize(): int { return 1000; }

but always same problem !!!

Any idea please ?

0 likes
1 reply
Rooligan's avatar

Maatwebsite/Excel is based on PHPSpreadsheet. PHPSpreadsheet has a pretty high memory load on the server. Especially when working with a lot of rows.

Try using a different Excel generator like cyber-duck/laravel-excel or any other based on box/spout or openspout/openspout.

Please or to participate in this conversation.