{"id":33951862,"url":"https://github.com/overlu/mini-excel","last_synced_at":"2026-05-27T18:31:11.321Z","repository":{"id":239998664,"uuid":"801416718","full_name":"overlu/mini-excel","owner":"overlu","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-16T11:06:59.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-14T07:52:05.023Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/overlu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-16T07:32:33.000Z","updated_at":"2024-05-16T11:07:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"552afd66-352b-4460-a5a6-9f328a5ea2a7","html_url":"https://github.com/overlu/mini-excel","commit_stats":null,"previous_names":["overlu/mini-excel"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/overlu/mini-excel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overlu%2Fmini-excel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overlu%2Fmini-excel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overlu%2Fmini-excel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overlu%2Fmini-excel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/overlu","download_url":"https://codeload.github.com/overlu/mini-excel/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overlu%2Fmini-excel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33579665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-12-12T19:09:50.326Z","updated_at":"2026-05-27T18:31:11.315Z","avatar_url":"https://github.com/overlu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e 感谢 rap2hpoutre/fast-excel 提供了优秀扩展 具体使用说明请传送至 https://github.com/rap2hpoutre/fast-excel\n\n## Quick start\n\nInstall via composer:\n\n```\ncomposer require overlu/mini-excel\n```\n\nExport a Model to `.xlsx` file:\n\n```php\nuse MiniExcel\\Excel;\nuse App\\Models\\User;\n\n// Load users\n$users = User::all();\n\n// Export all users\n(new Excel($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 Excel($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 Excel($invoices))-\u003eexport('invoices.csv');\n```\n\nExport only some attributes specifying columns names:\n\n```php\n(new Excel(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 Excel(User::all()))-\u003edownload('file.xlsx');\n```\n\n## Import\n\n`import` returns a Collection:\n\n```php\n$collection = (new Excel)-\u003eimport('file.xlsx');\n```\n\nImport a `csv` with specific delimiter, enclosure characters and \"gbk\" encoding:\n\n```php\n$collection = (new Excel)-\u003econfigureCsv(';', '#', 'gbk')-\u003eimport('file.csv');\n```\n\nImport and insert to database:\n\n```php\n$users = (new Excel)-\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\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\nExcel::data($list)-\u003eexport('file.xlsx');\n````\n\n## Global helper\n\nExcel provides a convenient global helper to quickly instantiate the Excel class anywhere in a Laravel application.\n\n```php\n$collection = Excel()-\u003eimport('file.xlsx');\nExcel($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 Excel($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 Excel)-\u003eimportSheets('file.xlsx');\n```\n\nYou can also import a specific sheet by its number:\n\n```php\n$users = (new Excel)-\u003esheet(3)-\u003eimport('file.xlsx');\n```\n\nImport multiple sheets with sheets names:\n\n```php\n$sheets = (new Excel)-\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 Excel(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 Excel($list))\n    -\u003eheaderStyle($header_style)\n    -\u003erowsStyle($rows_style)\n    -\u003edownload('file.xlsx');\n```\n\n## Why?\n\nExcel 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| Excel  | 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%2Foverlu%2Fmini-excel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foverlu%2Fmini-excel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foverlu%2Fmini-excel/lists"}