PHPackages                             phpdot/sheets - 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. phpdot/sheets

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

phpdot/sheets
=============

00PHP

Pushed 1mo agoCompare

[ Source](https://github.com/phpdot/sheets)[ Packagist](https://packagist.org/packages/phpdot/sheets)[ RSS](/packages/phpdot-sheets/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

phpdot/sheets
=============

[](#phpdotsheets)

Streaming, low-memory XLSX reader and writer for the PHPdot ecosystem. Read and write spreadsheets of **any size in constant memory** — the engine streams each row straight to and from a `zip://` part, so a million-row export costs the same few megabytes as a hundred-row one. The entire API is one injectable service and a chain of immutable builders: inject `Sheets`, call `write()` or `read()`, and decorate the workbook, sheets, rows and cells it hands back. Charts, images, conditional formatting and data validation are always on. Reading untrusted uploads is guarded against zip bombs, zip-slip and XXE by default, and the whole engine is coroutine-safe under Swoole.

Table of Contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Architecture](#architecture)
- [Testing](#testing)
- [License](#license)

Requirements
------------

[](#requirements)

RequirementConstraintPHP`>= 8.5``ext-zip``*``ext-mbstring``*``ext-xmlreader``*``ext-simplexml``*`Installation
------------

[](#installation)

```
composer require phpdot/sheets
```

Usage
-----

[](#usage)

### Writing

[](#writing)

Inject `SheetsInterface`, open a workbook, add sheets and rows, and `save()`. Rows stream to the `zip://`part one at a time, so memory stays flat regardless of size:

```
use PHPdot\Sheets\SheetsInterface;

final class SalesExport
{
    public function __construct(private readonly SheetsInterface $sheets) {}

    public function export(string $path): void
    {
        $xlsx  = $this->sheets->write($path);
        $sheet = $xlsx->addSheet('Sales');

        $sheet->header(['Product', 'Units', 'Revenue']);
        $sheet->addRow(['Widget', 120, 3600.50]);
        $sheet->addRow(['Gadget',  80, 2400.00]);

        $xlsx->save();
    }
}
```

Every `add*()` returns the child you decorate — `addSheet()` → a sheet, `addRow()` → a row, `addCell()` → a typed cell. Types are picked by value or pinned fluently: `addCell('00123')->asText()` keeps the leading zeros, `addCell('=SUM(B:B)')->asFormula()` writes a formula, and plain scalar rows infer their own types. Styling, layout, charts, images, conditional formatting and data validation all chain off the sheet (`$sheet->addChart('bar')`, `$cell->format('currency_usd')`) — enums power them underneath, but you import none of them.

### Reading

[](#reading)

`read()` streams rows back through `XMLReader`; iterate records keyed by the header row:

```
$in = $this->sheets->read($path);

foreach ($in->sheet('Sales')->records() as $row) {
    echo "{$row['Product']}: {$row['Revenue']}\n";
}
```

The reader never extracts to disk (no zip-slip), disables XML external entities (no XXE), and refuses decompression bombs by default — so it is safe to point at untrusted uploads.

Architecture
------------

[](#architecture)

`Sheets` is the injected `#[Singleton]` façade and the only class you import; it implements `SheetsInterface`. `write()` hands back a `Builder\Workbook`, `read()` a `Builder\ReadWorkbook` — a thin, immutable builder layer you chain through. Underneath, `Engine\Xlsx\Writer` streams each row straight into the `zip://` part and `Engine\Xlsx\Reader` streams them back through `XMLReader`; `Engine\Feature` supplies charts, images, conditional formatting and validation, and `Engine\Model`/`Engine\Support` hold the cells, styles, and helpers. The Builder layer is a façade — the Engine does the work, and application code almost never names it.

 ```
graph TD
    SHEETS["Sheets#[Singleton] — inject this (SheetsInterface)"]
    WB["Builder\\Workbook / Sheet / Row / Cellimmutable fluent façade"]
    RWB["Builder\\ReadWorkbook / ReadSheetthe read side"]
    WRITER["Engine\\Xlsx\\Writerstreams rows → zip:// part"]
    READER["Engine\\Xlsx\\Readerstreams rows ← XMLReader"]
    FEATURE["Engine\\Featurecharts · images · formatting · validation"]

    SHEETS -->|write| WB
    SHEETS -->|read| RWB
    WB --> WRITER
    RWB --> READER
    WB --> FEATURE
    WRITER --> FEATURE
```

      Loading Testing
-------

[](#testing)

```
composer install
composer test        # PHPUnit — includes zip-bomb / XXE / zip-slip hardening suites
composer analyse     # PHPStan, level max + strict rules
composer cs-check    # PHP-CS-Fixer
composer check       # All three
```

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

This repository is a **read-only mirror**. The canonical source lives in [phpdot/monorepo](https://github.com/phpdot/monorepo); pull requests and issues are handled there: [pulls](https://github.com/phpdot/monorepo/pulls) · [issues](https://github.com/phpdot/monorepo/issues).

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance60

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/62e82421bda4b5d6ba9a47ba6d88caca060dcd0d1a2862f351f3a97657385db0?d=identicon)[phpdot](/maintainers/phpdot)

---

Top Contributors

[![phpdot](https://avatars.githubusercontent.com/u/252500?v=4)](https://github.com/phpdot "phpdot (3 commits)")

---

Tags

excelooxmlphpspreadsheetstreamingxlsx

### Embed Badge

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

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

###  Alternatives

[tarfin-labs/easy-pdf

Makes pdf processing easy.

1719.9k](/packages/tarfin-labs-easy-pdf)[akeneo-labs/excel-connector-bundle

Akeneo PIM Excel connector bundle

166.4k](/packages/akeneo-labs-excel-connector-bundle)

PHPackages © 2026

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