laravel-spreadsheet maintained by elliotghorbani
About this package
This package allows you to export from your database as csv dynamically.
NOTE: Import feature is not added yet.
Installation
composer require elliotghorbani/laravel-spreadsheet
php artisan vendor:publish --provider="ElliotGhorbani\LaravelSpreadsheet\SpreadsheetServiceProvider"
In the generated config file you can override the table name under "spreadsheet_table" key.
php artisan migrate
Usage
-
Make a GET request to "/spreadsheet/tables" It returns all tables of your database.
-
Make a POST request to "/spreadsheet/columns" with a parameter name "table_name".
It returns all columns of the specified table. So than you can select desired columns and their position to be included in the spreadsheet. Please read NOTE 6.
- Make a POST request to "/spreadsheet/filter-columns" with a parameter name "table_name".
It returns all columns of the specified table that can be filtered with their datatype so that you can generate a form. Please read NOTE 7.
- Make a POST request to "/spreadsheet" with below parameters.
Your desired criteria is now created on database. So that you can use it again later.
- Make a GET request to "/spreadsheet/export/{export}"
A csv file containing the desired column and their positions with the filter applied is returned.
NOTE 1: "/spreadsheet" is a restfull route.
NOTE 2: Supported operators are "=", "!=", "<", ">", "<>". The last one ("<>") act as between.
NOTE 3: You can add middlewares and a prefix to routes of this package in config.
NOTE 4: You change csv delimiter in config.
NOTE 5: If you want to modify returned rows (unset or add a column for example), you can implement HasCustomExportRow interface in you eloquent modal and add it in config file under "table_model_map" key*.
NOTE 6: If you want to unset a column so that user is not able to request it, you can implement HasCustomExportAvailableColumns interface.
NOTE 7: If you want to unset a column so that user is not able to filter it, you can implement HasCustomExportAvailableFilterColumns interface.
Contributing
Thank you for considering contributing to the Laravel Spreadsheet!
License
The Laravel Spreadsheet is open-sourced software licensed under the MIT license.