{"id":13452963,"url":"https://github.com/rap2hpoutre/fast-excel","last_synced_at":"2025-05-15T01:00:43.773Z","repository":{"id":41555463,"uuid":"128174809","full_name":"rap2hpoutre/fast-excel","owner":"rap2hpoutre","description":"🦉 Fast Excel import/export for Laravel","archived":false,"fork":false,"pushed_at":"2025-02-18T12:51:22.000Z","size":229,"stargazers_count":2194,"open_issues_count":89,"forks_count":255,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-05-01T03:03:33.834Z","etag":null,"topics":["csv","excel","fast","hacktoberfest","laravel","laravel-package","memory-efficiency","php","xlsx"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rap2hpoutre.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"rap2hpoutre","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2018-04-05T07:49:06.000Z","updated_at":"2025-04-29T04:38:34.000Z","dependencies_parsed_at":"2024-06-03T09:50:21.583Z","dependency_job_id":"d18e12d9-2dad-45c4-a946-2085de675ccb","html_url":"https://github.com/rap2hpoutre/fast-excel","commit_stats":{"total_commits":170,"total_committers":34,"mean_commits":5.0,"dds":0.611764705882353,"last_synced_commit":"c6d2b8b707b85f7c43028d3b4cc969388d8b6c17"},"previous_names":[],"tags_count":63,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rap2hpoutre%2Ffast-excel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rap2hpoutre%2Ffast-excel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rap2hpoutre%2Ffast-excel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rap2hpoutre%2Ffast-excel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rap2hpoutre","download_url":"https://codeload.github.com/rap2hpoutre/fast-excel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252392506,"owners_count":21740523,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csv","excel","fast","hacktoberfest","laravel","laravel-package","memory-efficiency","php","xlsx"],"created_at":"2024-07-31T08:00:29.430Z","updated_at":"2025-05-07T12:48:30.043Z","avatar_url":"https://github.com/rap2hpoutre.png","language":"PHP","funding_links":["https://github.com/sponsors/rap2hpoutre"],"categories":["Popular Packages","Paquetes utiles"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/36028424/40173202-9a03d68a-5a03-11e8-9968-6b7e3b4f8a1b.png\"\u003e\n\u003c/p\u003e\n\n[![Version](https://poser.pugx.org/rap2hpoutre/fast-excel/version?format=flat)](https://packagist.org/packages/rap2hpoutre/fast-excel)\n[![License](https://poser.pugx.org/rap2hpoutre/fast-excel/license?format=flat)](https://packagist.org/packages/rap2hpoutre/fast-excel)\n[![StyleCI](https://github.styleci.io/repos/128174809/shield?branch=master)](https://github.styleci.io/repos/128174809?branch=master)\n[![Tests](https://github.com/rap2hpoutre/fast-excel/actions/workflows/tests.yml/badge.svg)](https://github.com/rap2hpoutre/fast-excel/actions/workflows/tests.yml)\n[![Total Downloads](https://poser.pugx.org/rap2hpoutre/fast-excel/downloads)](https://packagist.org/packages/rap2hpoutre/fast-excel)\n\nFast Excel import/export for Laravel, thanks to [Spout](https://github.com/box/spout).\nSee [benchmarks](#benchmarks) below.\n\n## Quick start\n\nInstall via composer:\n\n```\ncomposer require rap2hpoutre/fast-excel\n```\n\nExport a Model to `.xlsx` file:\n\n```php\nuse Rap2hpoutre\\FastExcel\\FastExcel;\nuse App\\User;\n\n// Load users\n$users = User::all();\n\n// Export all users\n(new FastExcel($users))-\u003eexport('file.xlsx');\n```\n\n## Export\n\nExport a Model or a **Collection**:\n\n```php\n$list = collect([\n    [ 'id' =\u003e 1, 'name' =\u003e 'Jane' ],\n    [ 'id' =\u003e 2, 'name' =\u003e 'John' ],\n]);\n\n(new FastExcel($list))-\u003eexport('file.xlsx');\n```\n\nExport `xlsx`, `ods` and `csv`:\n\n```php\n$invoices = App\\Invoice::orderBy('created_at', 'DESC')-\u003eget();\n(new FastExcel($invoices))-\u003eexport('invoices.csv');\n```\n\nExport only some attributes specifying columns names:\n\n```php\n(new FastExcel(User::all()))-\u003eexport('users.csv', function ($user) {\n    return [\n        'Email' =\u003e $user-\u003eemail,\n        'First Name' =\u003e $user-\u003efirstname,\n        'Last Name' =\u003e strtoupper($user-\u003elastname),\n    ];\n});\n```\n\nDownload (from a controller method):\n\n```php\nreturn (new FastExcel(User::all()))-\u003edownload('file.xlsx');\n```\n\n## Import\n\n`import` returns a Collection:\n\n```php\n$collection = (new FastExcel)-\u003eimport('file.xlsx');\n```\n\nImport a `csv` with specific delimiter, enclosure characters and \"gbk\" encoding:\n\n```php\n$collection = (new FastExcel)-\u003econfigureCsv(';', '#', 'gbk')-\u003eimport('file.csv');\n```\n\nImport and insert to database:\n\n```php\n$users = (new FastExcel)-\u003eimport('file.xlsx', function ($line) {\n    return User::create([\n        'name' =\u003e $line['Name'],\n        'email' =\u003e $line['Email']\n    ]);\n});\n```\n\n## Facades\n\nYou may use FastExcel with the optional Facade. Add the following line to ``config/app.php`` under the ``aliases`` key.\n\n````php\n'FastExcel' =\u003e Rap2hpoutre\\FastExcel\\Facades\\FastExcel::class,\n````\n\nUsing the Facade, you will not have access to the constructor. You may set your export data using the ``data`` method.\n\n````php\n$list = collect([\n    [ 'id' =\u003e 1, 'name' =\u003e 'Jane' ],\n    [ 'id' =\u003e 2, 'name' =\u003e 'John' ],\n]);\n\nFastExcel::data($list)-\u003eexport('file.xlsx');\n````\n\n## Global helper\n\nFastExcel provides a convenient global helper to quickly instantiate the FastExcel class anywhere in a Laravel application.\n\n```php\n$collection = fastexcel()-\u003eimport('file.xlsx');\nfastexcel($collection)-\u003eexport('file.xlsx');\n```\n\n## Advanced usage\n\n### Export multiple sheets\n\nExport multiple sheets by creating a `SheetCollection`:\n\n```php\n$sheets = new SheetCollection([\n    User::all(),\n    Project::all()\n]);\n(new FastExcel($sheets))-\u003eexport('file.xlsx');\n```\n\nUse index to specify sheet name:\n```php\n$sheets = new SheetCollection([\n    'Users' =\u003e User::all(),\n    'Second sheet' =\u003e Project::all()\n]);\n```\n\n### Import multiple sheets\n\nImport multiple sheets by using `importSheets`:\n\n```php\n$sheets = (new FastExcel)-\u003eimportSheets('file.xlsx');\n```\n\nYou can also import a specific sheet by its number:\n\n```php\n$users = (new FastExcel)-\u003esheet(3)-\u003eimport('file.xlsx');\n```\n\nImport multiple sheets with sheets names:\n\n```php\n$sheets = (new FastExcel)-\u003ewithSheetsNames()-\u003eimportSheets('file.xlsx');\n```\n\n### Export large collections with chunk\n\nExport rows one by one to avoid `memory_limit` issues [using `yield`](https://www.php.net/manual/en/language.generators.syntax.php):\n\n```php\nfunction usersGenerator() {\n    foreach (User::cursor() as $user) {\n        yield $user;\n    }\n}\n\n// Export consumes only a few MB, even with 10M+ rows.\n(new FastExcel(usersGenerator()))-\u003eexport('test.xlsx');\n```\n\n### Add header and rows style\n\nAdd header and rows style with `headerStyle` and `rowsStyle` methods.\n\n```php\nuse OpenSpout\\Common\\Entity\\Style\\Style;\n\n$header_style = (new Style())-\u003esetFontBold();\n\n$rows_style = (new Style())\n    -\u003esetFontSize(15)\n    -\u003esetShouldWrapText()\n    -\u003esetBackgroundColor(\"EDEDED\");\n\nreturn (new FastExcel($list))\n    -\u003eheaderStyle($header_style)\n    -\u003erowsStyle($rows_style)\n    -\u003edownload('file.xlsx');\n```\n\n## Why?\n\nFastExcel is intended at being Laravel-flavoured [Spout](https://github.com/box/spout):\na simple, but elegant wrapper around [Spout](https://github.com/box/spout) with the goal\nof simplifying **imports and exports**. It could be considered as a faster (and memory friendly) alternative\nto [Laravel Excel](https://laravel-excel.com/), with less features.\nUse it only for simple tasks.\n\n## Benchmarks\n\n\u003e Tested on a MacBook Pro 2015 2,7 GHz Intel Core i5 16 Go 1867 MHz DDR3.\nTesting a XLSX export for 10000 lines, 20 columns with random data, 10 iterations, 2018-04-05. **Don't trust benchmarks.**\n\n|   | Average memory peak usage  | Execution time |\n|---|---|---|\n| Laravel Excel  | 123.56 M  | 11.56 s |\n| FastExcel  | 2.09 M | 2.76 s |\n\nStill, remember that [Laravel Excel](https://laravel-excel.com/) **has many more features.**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frap2hpoutre%2Ffast-excel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frap2hpoutre%2Ffast-excel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frap2hpoutre%2Ffast-excel/lists"}