PHPackages                             fluentxlsx/fluentxlsx - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. fluentxlsx/fluentxlsx

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

fluentxlsx/fluentxlsx
=====================

A fluent, developer-friendly PHP library that unifies the functionalities of SimpleXLSX (for reading Excel files) and SimpleXLSXGen (for writing Excel files).

V1.0.0(6mo ago)011MITPHP

Since Oct 26Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/israel-007/fluentXLSX)[ Packagist](https://packagist.org/packages/fluentxlsx/fluentxlsx)[ RSS](/packages/fluentxlsx-fluentxlsx/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

FluentXLSX
==========

[](#fluentxlsx)

A fluent, developer-friendly PHP library that unifies the functionalities of [SimpleXLSX](https://github.com/shuchkin/simplexlsx) (for reading Excel files) and [SimpleXLSXGen](https://github.com/shuchkin/simplexlsxgen) (for writing Excel files).

With FluentXLSX, you can read, transform, and write Excel files in a single, consistent, and expressive API — without worrying about the differences between underlying libraries.

Features
--------

[](#features)

- Unified API for reading and writing XLSX files.
- Read from file or raw data.
- Select sheets by index, name, or active sheet.
- Access rows, headers, and individual cells (by Excel reference or index).
- Write new Excel files with multiple sheets.
- Save or download generated Excel files.
- Convert sheets to associative arrays (headers as keys).

Dependencies
------------

[](#dependencies)

This library is built on top of the following libraries which are provided by [shuchkin](https://github.com/shuchkin):

- [SimpleXLSX](https://github.com/shuchkin/simplexlsx) - lightweight reader for .xlsx files.
- [SimpleXLSXGen](https://github.com/shuchkin/simplexlsxgen) - lightweight generator for .xlsx files.

**Credit:**
Special thanks to [Sergey Shuchkin](https://github.com/shuchkin) for creating and maintaining [SimpleXLSX](https://github.com/shuchkin/simplexlsx) and [SimpleXLSXGen](https://github.com/shuchkin/simplexlsxgen), which make this project possible.

Both are stable, battle-tested libraries that handle the low-level complexity of the XLSX format.
FluentXLSX focuses on providing a clean, expressive, and fluent API over them.

Installation
------------

[](#installation)

Install via Composer:

```
composer require fluentxlsx/fluentxlsx
```

Usage Examples
--------------

[](#usage-examples)

Read an Excel file
==================

[](#read-an-excel-file)

```
use Fluentxlsx\Excel;

// Read from file, select sheet by index, get all rows
$reader = Excel::read('users.xlsx')
    ->sheet(0);

$rows = $reader->rows();
```

### Read from raw data

[](#read-from-raw-data)

```
use Fluentxlsx\Excel;

$data = file_get_contents('users.xlsx');
$reader = Excel::read($data);

$headers = $reader->headers();
```

### Select sheet by name or active sheet

[](#select-sheet-by-name-or-active-sheet)

```
use Fluentxlsx\Excel;

// By name
$reader = Excel::read('users.xlsx')->sheet('Sheet1');

// By active sheet
$reader = Excel::read('users.xlsx')->sheet('ACTIVE');
```

### Get specific rows or range

[](#get-specific-rows-or-range)

```
// First 5 rows
$rows = $reader->rows(5);

// Rows 2 to 10 (inclusive, 1-based)
$rows = $reader->rows([2, 10]);
```

### Get explicit rows

[](#get-explicit-rows)

```
// Get rows 1, 3, and 5
$rows = $reader->rowsEx([1, 3, 5]);
```

### Get headers

[](#get-headers)

```
$headers = $reader->headers();
```

### Convert to associative array

[](#convert-to-associative-array)

```
$assoc = $reader->toAssoc();
// [
//   ['id' => 1, 'name' => 'Alice'],
//   ['id' => 2, 'name' => 'Bob'],
// ]
```

### Get all sheet names

[](#get-all-sheet-names)

```
$sheets = $reader->sheets();
```

### Get a cell by reference or index

[](#get-a-cell-by-reference-or-index)

```
// By Excel reference
$value = $reader->cell('B3');

// By row and column (1-based)
$value = $reader->cellEx(3, 2); // Row 3, Column 2 (B)
$value = $reader->cellEx(3, 'B');
```

Direct Access to SimpleXLSX Methods
-----------------------------------

[](#direct-access-to-simplexlsx-methods)

You can also use methods from the underlying SimpleXLSX library directly on the reader object returned by `Excel::read()`.
This allows you to access advanced features or methods not wrapped by FluentXLSX.

**Example:**

```
use Fluentxlsx\Excel;

// Get the dimension (rows, columns) of the first sheet
$reader = Excel::read('users.xlsx');
list($rows, $cols) = $reader->dimension();
```

Other SimpleXLSX methods can be used in the same way.
Refer to the [SimpleXLSX documentation](https://github.com/shuchkin/simplexlsx#examples) for more details.

Write an Excel file
===================

[](#write-an-excel-file)

```
use Excel\Excel;

Excel::write()
    ->addSheet('Users', [
        ['ID', 'Name', 'Email'],
        [1, 'John Doe', 'john@example.com'],
        [2, 'Jane Doe', 'jane@example.com'],
    ])
    ->save('users.xlsx');

    #This creates a file named users.xlsx with one sheet named Users.
```

Creating and Managing Sheets
----------------------------

[](#creating-and-managing-sheets)

### Add a new sheet

[](#add-a-new-sheet)

```
Excel::write()
    ->addSheet('Products', [
        ['ID', 'Product Name', 'Price'],
        [1, 'Keyboard', 45],
        [2, 'Mouse', 25],
    ])
    ->save('products.xlsx');
```

### Add multiple sheets

[](#add-multiple-sheets)

```
Excel::write()
    ->addSheet('Customers', [['ID', 'Name'], [1, 'Alice']])
    ->addSheet('Orders', [['OrderID', 'CustomerID'], [1, 1]])
    ->save('sales.xlsx');
```

### Select an existing sheet to work with

[](#select-an-existing-sheet-to-work-with)

```
Excel::write()
    ->sheet('Users')
    ->cell('B2', 'David')
    ->save('updated_users.xlsx');
```

- If sheet() is not called, the first sheet is selected by default.

Writing Cell Values
-------------------

[](#writing-cell-values)

### Write a value using Excel notation

[](#write-a-value-using-excel-notation)

```
Excel::write()
    ->sheet('Data')
    ->cell('A1', 'Hello')
    ->cell('B2', 123)
    ->cell('C3', '=SUM(B2:B10)')
    ->save('sheet.xlsx');
```

### Write using row/column coordinates

[](#write-using-rowcolumn-coordinates)

```
Excel::write()
    ->cellEx(3, 'B', 'Price')
    ->cellEx(4, 'C', 100)
    ->save('cells.xlsx');
```

- The cell() and cellEx() methods automatically create intermediate rows or columns if they don’t exist.

Writing Rows and Data Arrays
----------------------------

[](#writing-rows-and-data-arrays)

### Add a single row

[](#add-a-single-row)

```
Excel::write()
    ->addRow(['Name', 'Email', 'Phone'])
    ->addRow(['John', 'john@example.com', '12345'])
    ->save('contacts.xlsx');
```

### Add multiple rows at once

[](#add-multiple-rows-at-once)

```
Excel::write()
    ->rows([
        ['ID', 'Name', 'Score'],
        [1, 'Alice', 90],
        [2, 'Bob', 85],
    ])
    ->save('scores.xlsx');
```

Saving and Downloading
----------------------

[](#saving-and-downloading)

### Save to file

[](#save-to-file)

```
Excel::write()
    ->addSheet('Sheet1', [['Name', 'Age'], ['John', 25]])
    ->save('output.xlsx');
```

### Output to browser for download

[](#output-to-browser-for-download)

```
Excel::write()
    ->addSheet('Report', [['Month', 'Revenue'], ['Jan', 1000]])
    ->download('report.xlsx');
```

### Get binary data (e.g., to send as attachment)

[](#get-binary-data-eg-to-send-as-attachment)

```
$data = Excel::write()
    ->addSheet('Users', [['ID', 'Name'], [1, 'Raymond']])
    ->toString();
```

Accessing SimpleXLSXGen Directly
--------------------------------

[](#accessing-simplexlsxgen-directly)

You can also use methods from the underlying SimpleXLSXGen library directly on the reader object returned by `Excel::write()`.
This allows you to access advanced features or methods not wrapped by FluentXLSX.

Refer to the [SimpleXLSXGen documentation](https://github.com/shuchkin/simplexlsxgen#examples) for more details.

Contribution
------------

[](#contribution)

PRs and issues are welcome! Please open a GitHub issue to discuss new ideas, bugs, or feature requests.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance71

Regular maintenance activity

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

195d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b6089fd8d3ecba23738d9118e9232d28e678b02e7ef4415ac9ea6010e452862?d=identicon)[israel-007](/maintainers/israel-007)

---

Top Contributors

[![israel-007](https://avatars.githubusercontent.com/u/76886811?v=4)](https://github.com/israel-007 "israel-007 (4 commits)")

---

Tags

excelexcel-exportexcel-importexcelreaderexcelwriter

### Embed Badge

![Health badge](/badges/fluentxlsx-fluentxlsx/health.svg)

```
[![Health](https://phpackages.com/badges/fluentxlsx-fluentxlsx/health.svg)](https://phpackages.com/packages/fluentxlsx-fluentxlsx)
```

###  Alternatives

[phpoffice/phpspreadsheet

PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine

13.9k293.5M1.2k](/packages/phpoffice-phpspreadsheet)[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M100](/packages/spatie-browsershot)[smalot/pdfparser

Pdf parser library. Can read and extract information from pdf file.

2.7k34.5M216](/packages/smalot-pdfparser)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.1k57.6M128](/packages/openspout-openspout)[keboola/csv

Keboola CSV reader and writer

1451.8M21](/packages/keboola-csv)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
