์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค
memory_limit = 1536M-๋ ์ค์ ํ ์ ์์
๋ด ์ฝ๋
Excel::download(new ReportExport($data), 'excel.xlsx');
$data
500000 ๊ฐ์ ํ์ผ๋ก ๋ฐ์ดํฐ ์์ง +
๊ทธ๋ ๊ฒ ๋ง์ ๋ฐ์ดํฐ๋ฅผ ์ด๋ป๊ฒ ์ธ ์ ์์ต๋๊น?
๋ณด๊ธฐ ํ์ผ์ ์ฝ์ ๋ PHP ํ๋ก์ธ์ค์ ๋ฉ๋ชจ๋ฆฌ๊ฐ ๋ถ์กฑํฉ๋๋ค. ๋๋ 500000 ํ์ด FromView ์ ๋ต์ ๋๋ฌด ๋ง์ ๊ฒ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค. ์ด ๊ธฐ์ฌ๊ฐ ์ทจํ ์ ๊ทผ ๋ฐฉ์์ ์๋ํด ๋ณผ ์ ์์ต๋๋ค : https://stefanzweifel.io/posts/lazy-collections-in-laravel-excel/
๋ณด๊ธฐ ํ์ผ์ ์ฝ์ ๋ PHP ํ๋ก์ธ์ค์ ๋ฉ๋ชจ๋ฆฌ๊ฐ ๋ถ์กฑํฉ๋๋ค. ๋๋ 500000 ํ์ด FromView ์ ๋ต์ ๋๋ฌด ๋ง์ ๊ฒ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค. ์ด ๊ธฐ์ฌ๊ฐ ์ทจํ ์ ๊ทผ ๋ฐฉ์์ ์๋ํด ๋ณผ ์ ์์ต๋๋ค : https://stefanzweifel.io/posts/lazy-collections-in-laravel-excel/
Laravel ๋ฒ์ 5.5. *๋ฅผ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์ cursor ()๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ ๋ฐ์ดํฐ๋ฒ ์ด์ค์์ ์ด๋ฌํ ๊ณ์ฐ์ ํ์ฉํ์ง ์๊ธฐ ๋๋ฌธ์ PHP์ ๊ณ์ฐ์ ํตํด ๋ฐ์ดํฐ๋ฒ ์ด์ค์์ ๋ฐ์ดํฐ๋ฅผ ์ป์ต๋๋ค. ์ด์จ๋ ์์ฑ๊ธฐ Excel ํ์ผ์ ์ ๊ณตํ๊ธฐ ์ ์ 500,000 ํ์ ๋ฐฐ์ด์ ๊ฐ๊ฒ๋ฉ๋๋ค.
@patrickbrouwers ๊ธฐ์ฌ์์ ์ ๊ทผ ๋ฐฉ์์ ์๋ํ์ง๋ง ๋ค์๊ณผ ๊ฐ์ด ์ป์ต๋๋ค.
Return value of Maatwebsite\Excel\QueuedWriter::exportCollection() must be an instance of Illuminate\Support\Collection, instance of Illuminate\Support\LazyCollection returned
@fedeisas ์ด๋ค ๋ฒ์ ์ laravel์ ์ฌ์ฉํ๊ณ ์์ต๋๊น?
์๋ ํ์ธ์.
laravel/framework v6.18.1 The Laravel Framework.
maatwebsite/excel 3.1.19 Supercharged Excel exports and imports in Laravel
phpoffice/phpspreadsheet 1.11.0 PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine
ํ๋ ์ฐ๊ธฐ๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค. ๊ทธ๊ฒ ๋ฌธ์ ์ผ๊น์?
๋ถ์ฐ ์์
์ (S3 ์ฌ์ฉ)์์ ๋ด๋ณด๋ด๊ธฐ๋ฅผ ์ํํ๋ ค๊ณ ํ๋๋ฐ FromQuery
๊ฐ ๊ณ ํต์ค๋ฝ๊ฒ ๋๋ฆฝ๋๋ค (3 ๋ง ํ ๋ด๋ณด๋ด๊ธฐ์ ๊ฒฝ์ฐ 1 ์๊ฐ).
๊ทธ๋์ ๋๋ ์ด์์ด ๊ฒ์ผ๋ฅธ ์ปฌ๋ ์
๊ณผ cursor()
๋ก ์ ํํ๋ ค๊ณ ํฉ๋๋ค.
@fedeisas ์ฌ์ฉ ๋๊ธฐ์ด์ด ์ค๋ฅ๋ก ์ธํด ์คํจํ์ต๋๋ค.
Return value of Maatwebsite\Excel\QueuedWriter::exportCollection() must be an instance of Illuminate\Support\Collection, instance of Illuminate\Support\LazyCollection returned
ํ์ง๋ง Excel :: download๋ ๊ด์ฐฎ์ต๋๋ค.
์ฌ์ ํ FromQuery ๊ด์ฌ์ฌ ๋๋ 512M ๋ฉ๋ชจ๋ฆฌ ์ค์ ์ผ๋ก LazyCollection์ผ๋ก 60K ๋ฐ์ดํฐ๋ฅผ ๋ด๋ณด๋ผ ์ ์์ต๋๋ค.
์ด๊ฒ์ ๊ตฌํํ๋ ๋ค๋ฅธ ์ค์ ์ ๋ฌด์์
๋๊น?
https://stefanzweifel.io/posts/lazy-collections-in-laravel-excel/
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
@fedeisas ์ฌ์ฉ ๋๊ธฐ์ด์ด ์ค๋ฅ๋ก ์ธํด ์คํจํ์ต๋๋ค.
Return value of Maatwebsite\Excel\QueuedWriter::exportCollection() must be an instance of Illuminate\Support\Collection, instance of Illuminate\Support\LazyCollection returned
ํ์ง๋ง Excel :: download๋ ๊ด์ฐฎ์ต๋๋ค.