SpartnerNL / Laravel-Excel

🚀 Supercharged Excel exports and imports in Laravel
https://laravel-excel.com
MIT License
12.27k stars 1.92k forks source link

Laravel-Excel for "big data" #2907

Closed jeanali closed 3 years ago

jeanali commented 3 years ago

Prerequisites

Description

I have like more than 30,000 products in DB and I need to export them, I have two question:

my test code

(new ExportProducts()->queue('products.xlsx')->chain([

    // new NotifyMerchantFileExport(request()->user()),

 ]);
ghost commented 3 years ago

Thanks for submitting the ticket. Unfortunately the information you provided is incomplete. We need to know which version you use and how to reproduce it. Please include code examples. Before we can pick it up, please check (https://github.com/Maatwebsite/Laravel-Excel/blob/3.1/.github/ISSUE_TEMPLATE.md) and add the missing information. To make processing of this ticket a lot easier, please make sure to check (https://laravel-excel.maatwebsite.nl/3.1/getting-started/contributing.html) and double-check if you have filled in the issue template correctly. This will allow us to pick up your ticket more efficiently. Issues that follow the guidelines correctly will get priority over other issues.

patrickbrouwers commented 3 years ago

Is FromQuery OK with this size of data?

FromQuery chunks the query into smaller batches of data

In queue section how can I send the file to email after the queue is done?!

You have to chain a queued job, please refer to Laravel documentation on how to send an email

jeanali commented 3 years ago

here is a full answer:

https://stackoverflow.com/questions/64686685/export-large-data-from-db-using-laravel-excel

Ffoisal commented 3 years ago

``I am trying to export more than 10k data in my excel but it show time out or sometime show not reached. What is the best process to export large amount of data in excel. In the i gave mtycontroller and export code.

controller: function excel(){ return (new UsersExport())->download('invoices.xlsx'); } in the Export folder UsersExport.php file `<?php namespace App\Exports; use App\Models\TEST; use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\Exportable; use Maatwebsite\Excel\Concerns\FromQuery; use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithMapping; use Maatwebsite\Excel\Concerns\FromArray; use Illuminate\Contracts\Queue\ShouldQueue;

class UsersExport implements FromQuery, WithMapping, WithHeadings,ShouldQueue { /**

Code is ok. it exports data when it has less amount of data but its occur problem when it's time to export large amount of data. Please if anyone can suggest how can i solved this when it's time to export large data