Search by

lfiweb / spreadsheet-writer

lfiweb

Lightweight writer for XLSX and ODS spreadsheet files without formulas or reading support

Package info

github.com/lfiweb/spreadsheet-writer

pkg:composer/lfiweb/spreadsheet-writer

Statistics

Installs: 6

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-11-17 12:58 UTC

This package is auto-updated.

Last update: 2026-11-17 13:45:40 UTC


README

Lightweight PHP library for writing spreadsheet files in XLSX and ODS format. It is a replacement for phpoffice/phpspreadsheet in projects that only write simple tables and need none of its other features (formulas, reading, charts, etc.).

Requirements

  • PHP 8.3 or newer
  • ext-mbstring
  • ext-zlib

Usage

use SpreadsheetWriter\RichText;
use SpreadsheetWriter\Style\{Border, Font, HorizontalAlignment, Style};
use SpreadsheetWriter\Workbook;
use SpreadsheetWriter\Writer\Xlsx;

$workbook = new Workbook();
$sheet = $workbook->getActiveSheet();

// coordinates are 1-based: (column, row)
$sheet->setString(1, 1, (new RichText())->addText('Unit', new Font(color: '006268'))->addText(': m³'));
$sheet->mergeCells(1, 1, 3, 1);
$sheet->setString(1, 2, '1990');      // always text
$sheet->setValue(2, 2, '12.30');      // number 12.3, displayed as 12.30
$sheet->setStyle(1, 2, 3, 2, new Style(horizontal: HorizontalAlignment::Right, border: new Border(color: 'aaaaaa')));
$sheet->setColumnWidth(1, 20);
$sheet->setShowGridlines(false);

$binary = (new Xlsx())->write($workbook);

See docs/api.md for the API reference, the differences to PhpSpreadsheet and the mapping from its API.

Installation

composer require lfiweb/spreadsheet-writer

Development

The tests use PHPUnit and read the generated files back with phpoffice/phpspreadsheet, which is only a development dependency. They need ext-zip and ext-dom:

composer install
composer test

License

GPL-3.0-or-later