Skip to content
download excels wrap in zip
PHP
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src add config Mar 14, 2019
.gitignore init Aug 6, 2018
LICENSE Initial commit Aug 6, 2018
README.md update Aug 6, 2018
composer.json

README.md

laravel-excel-zip

download excels wrap in zip

laravel-excel-zip is a solution to download a large excel. You can define when to chunk excels into a zip file.

Install

composer require cblink/laravel-excel-zip -vvv

Usage

run command to create config/excel_zip.php

php artisan vendor:publish --provider="Cblink\ExcelZip\ExcelZipServiceProvider"

Export

use CustomCollection in your Export and Don't define collection function

<?php

use Cblink\ExcelZip\CustomCollection;
use Maatwebsite\Excel\Concerns\FromCollection;

class MemberExport implements FromCollection
{
    use CustomCollection;
}

Controller

<?php

use Cblink\ExcelZip\ExcelZip;
use App\Http\Controllers\Controller;

class MemberController extends Controller
{
    // chunk by database(better!)
    public function export1(ExcelZip $excelZip, MemberExport $export)
    {
        $excelZip = $excelZip->setExport($export);
    
        Member::chunk(5000, function ($members) use ($excelZip) {
            $excelZip->excel($members);
        });
    
        return $excelZip->zip();
    }
    
    // chunk in laravel-excel-zip
    public function export2(ExcelZip $excelZip, MemberExport $export)
    {
        return $excelZip->download(Member::all(), $export);
    }
}
You can’t perform that action at this time.