Fast Excel Package for Laravel

Fast Excel Package for Laravel

https://ift.tt/38cceij

Fast Excel is a Laravel package for importing and exporting spreadsheets. It provides an elegant wrapper around Spout—a PHP package to read and write spreadsheet files in a quick and scalable way. It is capable of processing large files, all while keeping the memory usage low.

Here’s an example of exporting models or collections to an Excel file:

use Rap2hpoutre\FastExcel\FastExcel;
use App\User;

// Export a User model
$users = User::all();
(new FastExcel($users))->export('file.xlsx');

// Export a collection Collection
$list = collect([
    [ 'id' => 1, 'name' => 'Jane' ],
    [ 'id' => 2, 'name' => 'John' ],
]);

(new FastExcel($list))->export('file.xlsx');

You can use the download method to force the user’s browser to download a file:

return (new FastExcel(User::all()))->download('file.xlsx');

You can also import and export multiple sheets:

$sheets = new SheetCollection([
    User::all(),
    Project::all()
]);
(new FastExcel($sheets))->export('file.xlsx');

Learn More

You can learn more about this package, get full installation instructions, and view the source code on GitHub at rap2hpoutre/fast-excel.

Filed in:
News
/
laravel
/
packages

programming

via Laravel News https://ift.tt/14pzU0d

December 17, 2020 at 09:22AM