Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12201

How to export a lot of data from database to excel via laravel? [duplicate]

$
0
0

I have a little Laravel project that connected to Postgres database. There is a table sources that have 200k rows in it. Now I need to export them all to .xlsx. I found a most popular packages for that: Laravel-Excel and Fast-Excel... All of them have memory issues when I start exporting: Here is my code via Fast-Excel:

public function export(Request $request){    (new FastExcel(        (function () {            foreach (Source::cursor() as $data) {                yield $data;            }        })()    ))        ->export('reports/' . sprintf('Источники_%s_%s.xlsx', date('Y-m-d'), Str::random(6)));}

It crashed via

"Maximum execution time of 60 seconds exceeded" or "Allowed memory size..."

So my question is How to export a lot of data without using ini_set and any hardcode?

I tried Laravel-Excel and Fast-Excel - didn't helped, also I tried pure php script for export that didn't helped too


Viewing all articles
Browse latest Browse all 12201

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>