PHPackages                             fazton/excel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. fazton/excel

ActiveLibrary[File &amp; Storage](/categories/file-storage)

fazton/excel
============

Elegant Excel reader/writer facade over PhpSpreadsheet with memory-optimized APIs and rich features.

00PHP

Since Oct 30Pushed 6mo agoCompare

[ Source](https://github.com/Fazton/Excel)[ Packagist](https://packagist.org/packages/fazton/excel)[ RSS](/packages/fazton-excel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Excel Processing Module (Overview)
==================================

[](#excel-processing-module-overview)

[![Packagist Version](https://camo.githubusercontent.com/35d177e914d09c4856b52289ccf23cecf1dbc7c8fdfcfffcd5bbc520b7b95e72/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66617a746f6e2f657863656c2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/35d177e914d09c4856b52289ccf23cecf1dbc7c8fdfcfffcd5bbc520b7b95e72/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66617a746f6e2f657863656c2e7376673f7374796c653d666c61742d737175617265)[![Downloads](https://camo.githubusercontent.com/7c06240ba6607bdc0e58a2cd706b1aed03e4ce84ab09d1695d0dd13c2a134374/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66617a746f6e2f657863656c2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/7c06240ba6607bdc0e58a2cd706b1aed03e4ce84ab09d1695d0dd13c2a134374/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66617a746f6e2f657863656c2e7376673f7374796c653d666c61742d737175617265)[![PHP Version](https://camo.githubusercontent.com/c6d6c62cd15792a0aec7ede7aae46546f4cfd1b525c1fd8e1c43b4a94d864090/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f66617a746f6e2f657863656c2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/c6d6c62cd15792a0aec7ede7aae46546f4cfd1b525c1fd8e1c43b4a94d864090/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f66617a746f6e2f657863656c2e7376673f7374796c653d666c61742d737175617265)[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)

This project provides two powerful modules to work with Excel files:

- Excel Writer: Create and export spreadsheets with styling, merging, auto-sizing, properties, protections, and HTML to Excel conversion.
- Excel Reader: Read and process spreadsheets with column mapping, filters, iterators for large volumes, multi-sheet support, and utilities.

For full technical documentation, see the module pages under `docs/`.

1: Excel Writer (Summary)
-------------------------

[](#1-excel-writer-summary)

Full docs: `docs/excel_writer.md`

MethodSummary`create()`Instantiate writer and create an empty workbook`setFileName(string $fileName)`Set output file name and format`addSheet(string $name)`Add a sheet and set it active`renameSheet(int|string $indexOrName, string $newName)`Rename a sheet`setActiveSheet(int|string $indexOrName)`Select active sheet`writeData(array $rows, ?string $sheetName = null, bool $includeHeaders = true, array $options = [])`Append rows with optional headers and styles`setCell(string $cell, mixed $value, ?array $style = null)`Set a single cell`applyStyle(string $range, array $style)`Apply styles to range`writeHtml(string $html, ?string $sheetName = null, array $options = [])`Convert HTML table to Excel`autoSizeColumns(int $fromIndex = 1, ?int $toIndex = null, ?string $sheetName = null)`Auto-size columns by index range`mergeCells(string $range)`Merge cells in a range`setAutoFilter(string $range)`Enable auto filter on header range`setProperties(array $properties)`Set document properties`protectSheet(?string $sheetName = null, ?string $password = null, array $options = [])`Protect sheet`protectWorkbook(?string $password = null)`Protect workbook`configureWriter(array $options)`Performance and export options`save(?string $filePath = null, string $format = 'Xlsx')`Save to disk`download(string $fileName, string $format = 'Xlsx')`Stream to client`free()`Release resourcesLink: [docs/excel\_writer.md](docs/excel_writer.md)

2: Excel Reader (Summary)
-------------------------

[](#2-excel-reader-summary)

Full docs: `docs/excel_reader.md`

MethodSummary`load(string $filePath)`Load Excel file from path`setFileName(string $fileName)`Set file name for write mode`setActiveSheet(int|string $indexOrName)`Select active sheet`setSheet(int|string $indexOrName)`Alias for selecting sheet`addSheet(string $name)`Add sheet (write mode)`setColumns(array $columns)`Limit/map columns to read`skipHeader(bool $skip = true)`Skip the header row`startWhen(string $column, mixed $value, string $operator = '=')`Start when a condition matches`stopWhen(string $column, mixed $value, string $operator = '=')`Stop when a condition matches`excludeEmpty(bool $exclude = true)`Exclude empty rows`getData()`Return data as array`eachRow(callable $callback)`Iterate row-by-row`chunk(int $size, callable $callback)`Process in chunks`getSheetNames()`Get sheet names`getSheetCount()`Get sheet count`unmergeAllCells()`Unmerge all merged cells`getRowCount(?string $sheetName = null)`Row count`getColumnCount(?string $sheetName = null)`Column count`writeData(array $rows, ?string $sheetName = null, bool $includeHeaders = true)`Write mode export`save(string $filePath, string $format = 'Xlsx')`Save (write mode)`download(string $fileName, string $format = 'Xlsx')`Download (write mode)`free()`Release resourcesLink: [docs/excel\_reader.md](docs/excel_reader.md)

---

For detailed method descriptions, parameters, examples, and special cases, please visit the module documentation pages:

- [docs/excel\_writer.md](docs/excel_writer.md)
- [docs/excel\_reader.md](docs/excel_reader.md)

---

1. Package Description
----------------------

[](#1-package-description)

Fazton/Excel is an elegant facade over PhpSpreadsheet that simplifies reading and writing Excel and CSV files with a clear API, optimized memory usage, and features tailored for large datasets. It provides high-level utilities to:

- Export data with styles, merges, auto-filters, properties, protections, and HTML-to-Excel conversion.
- Read spreadsheets with column mapping, advanced filters (startsWith, endsWith, contains), type handling, efficient iteration (`eachRow`, `chunk`), and multi-sheet support.

2. System Requirements
----------------------

[](#2-system-requirements)

- PHP: `^8.0`
- Dependencies: `phpoffice/phpspreadsheet: ^1.29 || ^2.0`
- Recommended extensions (depending on formats and features used):
    - `ext-zip` for efficient `xlsx` read/write
    - `ext-mbstring` for robust string handling
    - `ext-gd` for image operations (if applicable)

3. Installation
---------------

[](#3-installation)

Install via Composer:

```
composer require fazton/excel
```

Autoload and basic usage (PSR-4):

```
