PHPackages                             baptouuuu/spreadsheet - 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. baptouuuu/spreadsheet

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

baptouuuu/spreadsheet
=====================

Spreadsheet object representation

1.0.0(9y ago)015MITPHPPHP ~7.0

Since Jul 16Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Baptouuuu/Spreadsheet)[ Packagist](https://packagist.org/packages/baptouuuu/spreadsheet)[ Docs](http://github.com/Baptouuuu/Spreadsheet)[ RSS](/packages/baptouuuu-spreadsheet/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Spreadsheet
===========

[](#spreadsheet)

`master``develop`[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5c56c389f62c8e0aff0d514da61f34eb0745967e2c5cd7f72ec8eea6b45a29ff/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f426170746f757575752f53707265616473686565742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Baptouuuu/Spreadsheet/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/630be4eec8c297146697e34c866985f3bd60456ca37d3ae7c2e5d730a602431c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f426170746f757575752f53707265616473686565742f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/Baptouuuu/Spreadsheet/?branch=develop)[![Code Coverage](https://camo.githubusercontent.com/73e8b39883564ed70e501363fcd169e214cb6e9ef55f8f1ded6473efbd44e9b1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f426170746f757575752f53707265616473686565742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Baptouuuu/Spreadsheet/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/a0e30e5831e6c391cfe6814d39cb5e67c85f655df7a2de01c2dbd87999111051/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f426170746f757575752f53707265616473686565742f6261646765732f636f7665726167652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/Baptouuuu/Spreadsheet/?branch=develop)[![Build Status](https://camo.githubusercontent.com/43f5a50cc2a17003d6051061eb23d578417da59bceceb8fd1f263134c4b9b3e2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f426170746f757575752f53707265616473686565742f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Baptouuuu/Spreadsheet/build-status/master)[![Build Status](https://camo.githubusercontent.com/47fd495eca3832de5a25199bf78d0cb879bb3975bb2f713f128edb406d568646/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f426170746f757575752f53707265616473686565742f6261646765732f6275696c642e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/Baptouuuu/Spreadsheet/build-status/develop)Library providing an object modeling of a spreadsheet (all objects are immutable). It comes with objects to build a spreadsheet out of a file and dump a spreadsheet into a file.

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

[](#installation)

```
composer require baptouuuu/spreadsheet
```

Usage
-----

[](#usage)

```
use Spreadsheet\{
    Spreadsheet,
    Sheet,
    Cell,
    Position
};

$sheet = new Sheet('sheet 1');
$sheet = $sheet
    ->add(
        new Cell(
            new Position('A', 1),
            'A1 value'
        )
    )
    ->add(
        new Cell(
            new Position('B', 2),
            'B2 value'
        )
    );
$spreadsheet = new Spreadsheet('My Spreadsheet');
$spreadsheet = $spreadsheet->add($sheet);
```

Transform a spreadsheet to a CSV
--------------------------------

[](#transform-a-spreadsheet-to-a-csv)

```
use Spreadsheet\{
    Writer\CsvWriter,
    Formatter\FormatterInterface,
    File\Csv
};
use Innmind\Immutable\Map;

$writer = new CsvWriter(';', true, new Map('string', FormatterInterface::class));
$file = $writer->write($spreadsheet);
$file instanceof Csv; //true
(string) $file->name(); //sheet 1.csv
(string) $file->content();
/*
A;B
A1;
;B2
*/
```

In case your spreadsheet contains more than one sheet, the writer will return an instance of [`DirectoryInterface`](https://github.com/Innmind/Filesystem/blob/develop/DirectoryInterface.php).

Building a spreadsheet from a CSV
---------------------------------

[](#building-a-spreadsheet-from-a-csv)

```
use Spreadsheet\{
    Reader\CsvReader,
    File\Csv,
    Position
};
use Innmind\Filesystem\Stream\StringStream;

$reader = new CsvReader(';', true);
$spreadsheet = $reader->read(
    new Csv(
        'sheet.csv',
        new StringStream(name(); //sheet
$spreadsheet->get('sheet')->get(new Position('A', 1))->value(); //A1
$spreadsheet->get('sheet')->get(new Position('B', 1))->value(); //B1
```

If you give an instance of [`DirectoryInterface`](https://github.com/Innmind/Filesystem/blob/develop/DirectoryInterface.php) to the reader, each file will be a sheet in your spreadhseet.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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

3585d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/851425?v=4)[Baptiste Langlade](/maintainers/Baptouuuu)[@Baptouuuu](https://github.com/Baptouuuu)

---

Top Contributors

[![Baptouuuu](https://avatars.githubusercontent.com/u/851425?v=4)](https://github.com/Baptouuuu "Baptouuuu (18 commits)")

---

Tags

spreadsheet

### Embed Badge

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

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

###  Alternatives

[phpoffice/phpspreadsheet

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

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

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

1.1k57.6M130](/packages/openspout-openspout)[asimlqt/php-google-spreadsheet-client

Google Spreadsheet PHP Client

5492.7M7](/packages/asimlqt-php-google-spreadsheet-client)[nuovo/spreadsheet-reader

Spreadsheet reader library for Excel, OpenOffice and structured text files

669863.2k8](/packages/nuovo-spreadsheet-reader)[faisalman/simple-excel-php

Easily parse / convert / write between Microsoft Excel XML / CSV / TSV / HTML / JSON / etc formats

582599.4k1](/packages/faisalman-simple-excel-php)[avadim/fast-excel-writer

Lightweight and very fast XLSX Excel Spreadsheet Writer in PHP

2951.2M7](/packages/avadim-fast-excel-writer)

PHPackages © 2026

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