Download the PHP package pocketframe/excel without Composer
On this page you can find all versions of the php package pocketframe/excel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pocketframe/excel
More information about pocketframe/excel
Files in pocketframe/excel
Package excel
Short Description A Pocketframe package for Excel/CSV import and export built on PhpSpreadsheet with support for styling, multiple sheets, and chunked processing.
License MIT
Informations about the package excel
Pocketframe Excel
A robust Pocketframe package for Excel and CSV import/export built on PhpSpreadsheet. It supports advanced features such as cell styling, multiple sheets, chunked processing for very large files, and auto-detection of CSV files.
Features
-
Auto-detection of file type: Process Excel (.xlsx, .xls) and CSV files seamlessly.
-
Chunked Reading: Use a custom ChunkReadFilter to limit memory usage by processing files in defined row chunks.
-
Advanced Export Options: Apply cell formatting and styling, create multi-sheet exports, and handle complex excel features like merged cells and formulas.
-
Easy to Use API: The package exposes a clean, static-style API through the Excel Mask that integrates with Pocketframe’s Storage, DataSet, and Response systems.
- Extensible: Use standard contracts for custom importer and exporter classes.
Installation
Install via Composer:
Usage
Importing Data
Generating an importer by running the following command:
[!important] You should not add Importer or Import to the file name. This will be added automatically and the file name will become
UsersImporter.php. If you add Importer or Import to the file name will now becomeUsersImporterImporter.phpwhich may not look nice. This also applies to the exporters.
This will generate a file named UsersImporter.php in the app/Excel/Imports directory. You can then customize the file accordingly.
[!NOTE] You can pass an entity name to the command to generate an importer for that entity. For example,
php pocket excel:create:importer Users --entity=Userwill generate an importer for the User entity.
Create an importer by implementing
Pocketframe\Excel\Contracts\ImporterInterface. For example, create a file at app/Excel/Imports/UsersImporter.php with the following content:
Import your Excel file (with optional chunking and sheet selection) in your controller:
[!tip] You can also check for duplicates in the
handlemethod. For example, you can check if a user with the same email already exists before saving it to the database. bash php pocket excel:create:exporter Users bash php pocket excel:create:exporter UserMulti --entity=User --multi
This will generate a file in the app/Excel/Exports directory named UserMultiExporter.php that includes the multi‑sheet boilerplate (with a sheets() method) and correctly references the User entity. You can then modify the file to customize the sheet names, columns, data, and styles.
Then export with:
API Reference
Excel Mask Methods
Imports data from a file.
Parameters:
-
$importerClass (string): The importer class name that implements Importer. -
$fileName (string): File name relative to the storage disk. -
$chunkSize (int|null): Optional chunk size for processing large files. $sheetName (string|null): Optional sheet name (defaults to active sheet).
Exports data using the provided exporter. Returns an instance for chaining (e.g., ->download()).
Parameters:
$exporterClass (string): The exporter class name that implements Exporter.
Downloads the generated spreadsheet. The writer auto-detects the file format based on extension.
All versions of excel with dependencies
phpoffice/phpspreadsheet Version 4.1.0
league/flysystem-local Version 3.x-dev