syspons / laravel-sheetable
Laravel Helper for spreadsheet im-/export
Installs: 1 004
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/syspons/laravel-sheetable
Requires
- berthott/laravel-scopeable: ^3.0.0
- berthott/laravel-targetable: ^3.0
- berthott/laravel-translatable: ^3.0
- haydenpierce/class-finder: ^0.4.3
- maatwebsite/excel: ^3.1
Requires (Dev)
- brianium/paratest: ^7.0
- doctrine/dbal: ^3.3
- orchestra/testbench: ^8.0
- phpunit/phpunit: ^10.0
- dev-main
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.0
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0.x-dev
- 2.0.0
- 1.0.28.346
- 1.0.27.364
- 1.0.26.346
- 1.0.25.193
- 1.0.24.193
- 1.0.23.259
- 1.0.22.309
- 1.0.21.309
- 1.0.21.243
- 1.0.20.216
- 1.0.19.90
- 1.0.18.90
- 1.0.17.90
- 1.0.16.90
- 1.0.15.90
- 1.0.14.90
- 1.0.13.90
- 1.0.12.90
- 1.0.10.132
- 1.0.4
- 1.0.3
- 1.0.1
- 1.0.0
- dev-feature/MON-346-filtered-export
- dev-feature/mon-90-caching-and-210-tests
This package is auto-updated.
Last update: 2025-10-21 11:25:16 UTC
README
A helper for importing and exporting Eloquent models.
Easily add import + export routes + controllers by adding a Trait to your model.
This package utilizes laravel-excel which is a wrapper around PhpSpreadsheet
Installation
$ composer require syspons/laravel-sheetable
Concept
The package provides an interface to the database using excel import and export. It can be used to create or update entities, not to delete them. For updating a unique identifier in the table is necessary.
Dropdownable
Plain data from the table will be shown in the export as is. However, there might be relations within the data, that shall be shown inside the export (or import).
These are defined by DropdownConfigs. These represent a relation within the excel. It is possible to include one to many and many to many relationships.
For every relation you'll find a dropdown in your excel to select one of the related entities.
There will be a workbook inside your spreadsheet that contains all related models, mapped to their key, in order to make it possible to import these relations as well.
Join
If you want more, than a single column of a relation joined to your export table, you will need to use the Join functionality. You have the possibility to add nested joins and to select any column of the joined table.
Usage
- Create your table and corresponding model, eg. with
php artisan make:model YourModel -m - Implement the
Sheetableinterface in your newly generated model. - The package will register the following routes:
- Export, get, post
yourmodels/export=> export all desired entities - Template, get
yourmodels/template=> export an empty spreadsheet - Import, post
yourmodels/import=> import a spreadsheet
- Export, get, post
Options
To change the default options use
$ php artisan vendor:publish --provider="syspons\Sheetable\SheetableServiceProvider" --tag="config"
- Inherited from laravel-targetable
namespace: String or array with one ore multiple namespaces that should be monitored for the configured trait. Defaults toApp\Models.namespace_mode: Defines the search mode for the namespaces.ClassFinder::STANDARD_MODEwill only find the exact matching namespace,ClassFinder::RECURSIVE_MODEwill find all subnamespaces. Defaults toClassFinder::STANDARD_MODE.prefix: Defines the route prefix. Defaults toapi.
- Formats
export_format: Defines the export format. Possible values are:XLSX,CSV,TSV,ODS,XLS,HTML,MPDF,DOMPDF,TCPDF. See the Laravel-Excel Documentation. Defaults toXLSX.import_format: Defines the import format. Possible values are:XLSX,CSV,TSV,ODS,XLS,SLK,XML,GNUMERIC,HTML. See the Laravel-Excel Documentation. Defaults toANY.
Architecture
- The package relies on laravel-targetable to connect specific functionality to Laravel model entities via contracts. (
Sheetable,Dropdownable). - The entrypoints to all functionality is provided by the
SheetControllerby utilizinglaravel-excel.SheetsExportis used to provide export + template functionality.SheetImportis used to provide import functionality.- Both rely on
SpreadsheetHelperandSpreadsheetUtilsfor core functionality.
ExportRequestimplements the rules for selecting entities or columns to export- The
SpreadsheetDropdownshelper implements all functionality connected to relations /Dropdownables. SpreadsheetJoinsandJoingather the join functionality.
Compatibility
Tested with Laravel 10.x.
License
See License File. Copyright © 2023 Jan Bladt.