fissible / transmark-xlsx
XLSX import/export for fissible/transmark: XlsxReader/XlsxWriter read and write a Workbook/Sheet/Cell model, sharing the OoxmlPackage zip/DOM layer with DocxReader/DocxWriter.
Requires
- php: ^8.2
- ext-dom: *
- ext-zip: *
- fissible/transmark: >=0.3 <1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpunit/phpunit: ^11.0
This package is auto-updated.
Last update: 2026-08-10 03:32:37 UTC
README
XLSX import/export for fissible/transmark: XlsxReader/XlsxWriter read and write a Workbook/Sheet/Cell spreadsheet model, sharing the Ooxml\OoxmlPackage zip/DOM layer that DocxReader/DocxWriter are built on.
Why a separate package?
fissible/transmark's canonical model is a flowing document tree (Document/Block/Inline) — it doesn't fit a spreadsheet grid. This package defines its own Workbook/Sheet/Cell model instead of forcing XLSX through the document model, while still reusing the shared OOXML zip-and-manifest foundation.
Requirements
- PHP ^8.2
- ext-dom, ext-zip
Installation
composer require fissible/transmark-xlsx
Usage
Reading an XLSX file
use Fissible\Transmark\Xlsx\XlsxReader; $bytes = file_get_contents('report.xlsx'); $workbook = (new XlsxReader())->read($bytes); $sheet = $workbook->sheet('Sheet1'); $sheet->cellAt('A1')->value(); // by A1-style reference $sheet->cell(1, 1)->value(); // by (row, col) coordinate — both address the same cell
Writing an XLSX file
use Fissible\Transmark\Xlsx\{Cell, Sheet, Workbook, XlsxWriter}; $sheet = new Sheet('Sheet1'); $sheet->setCellAt('A1', Cell::string('Hello, World.')); $sheet->setCellAt('A2', Cell::number(42.5)); $sheet->setCellAt('A3', Cell::boolean(true)); $sheet->setCellAt('A4', Cell::formula('A2', 42.5)); // formula text + last-known cached value $workbook = new Workbook(); $workbook->addSheet($sheet); $bytes = (new XlsxWriter())->write($workbook); file_put_contents('report.xlsx', $bytes);
The Cell model
Every cell has exactly one of five types (Fissible\Transmark\Xlsx\CellType):
String, Number (a float), Boolean, Formula, or Empty. A Formula
cell carries both the formula text and its last-computed cached value —
XLSX always stores both side by side (<f>/<v>), and Cell::formula()
preserves that:
$cell = Cell::formula('SUM(A1:A10)', 55.0); $cell->formulaText(); // 'SUM(A1:A10)' $cell->value(); // 55.0 — the cached result, not recomputed by this package
An unset cell reads back as Cell::empty(); XlsxWriter never writes empty
cells to the package.
Known limitations
t="inlineStr"cells (inline text instead of a shared-string index) are not read — seePROJECT.mdfor the full list of out-of-scope XLSX features (cell styles, merged cells, named ranges, formula evaluation, and more).
License
MIT