π PHP Extension for creating and reader XLSX files.
See the code
The chart below compares xlswriter with PhpSpreadsheet (the maintained successor to PHPExcel) when exporting an XLSX file, scaled all the way to Excel's row limit. Writing 1,048,576 rows Γ 10 columns, xlswriter is about 20Γ faster, and its fixed-memory mode keeps peak memory flat at ~30 MB no matter how many rows you write β whereas a pure-PHP library's memory grows with the data (β7 GB for the same file).

The two xlswriter modes track within ~10% of each other on time. Fixed-memory mode is marginally faster because it streams each row straight to disk and frees it immediately β a single pass, with no full in-memory model to build up and then serialize a second time at the end. The trade-off is that, unlike normal mode, it can no longer revisit a cell once it has been written (and its strings are stored inline rather than de-duplicated, so the file can be slightly larger). Normal mode keeps the whole workbook in memory, which is what lets you write cells in any order and re-style them before saving.
xlswriter is a PHP C Extension for Excel 2007+ XLSX files. It writes text, numbers, formulas, dates, charts, images and hyperlinks to new workbooks, opens existing files to edit them and save the result, reads their contents back, and evaluates formulas to a computed value. It supports features such as:
Both install methods below build from source, so the zlib development headers must be present first (they are often missing on minimal images):
# Debian / Ubuntu
apt-get install -y zlib1g-dev
# Alpine
apk add zlib-dev
# RHEL / CentOS / Fedora
yum install -y zlib-devel
Then install with either PECL or PIE:
PECL
pecl install xlswriter
PIE
PIE also builds from source and additionally needs
the autotools build chain (autoconf, make, a compiler and libtool). It can
install those missing build tools for you with --auto-install-build-tools, but
it cannot install zlib β make sure the headers above are in place first:
pie install --auto-install-build-tools viest/xlswriter
Test environment: Macbook Pro 13 inch, Intel Core i5, 16GB 2133MHz LPDDR3 Memory, 128GB SSD Storage.
Two memory modes export 1 million rows of data (27 columns, data is string)
1 million rows of data (1 columns, data is inter)
Includes extensive and detailed instructions that make it easy to get started with xlswriter.
composer require viest/php-ext-xlswriter-ide-helper:dev-master
This project exists thanks to all the people who contribute. [Contribute].
Become a financial contributor and help us sustain our community. [Contribute]
Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]
BSD License
44 followers Β· starred Mar 2023
58 followers Β· starred Mar 2024
72 followers Β· starred May 2026
6 followers Β· starred Nov 2017
π PHP Extension for creating and reader XLSX files.
See the code
The chart below compares xlswriter with PhpSpreadsheet (the maintained successor to PHPExcel) when exporting an XLSX file, scaled all the way to Excel's row limit. Writing 1,048,576 rows Γ 10 columns, xlswriter is about 20Γ faster, and its fixed-memory mode keeps peak memory flat at ~30 MB no matter how many rows you write β whereas a pure-PHP library's memory grows with the data (β7 GB for the same file).

The two xlswriter modes track within ~10% of each other on time. Fixed-memory mode is marginally faster because it streams each row straight to disk and frees it immediately β a single pass, with no full in-memory model to build up and then serialize a second time at the end. The trade-off is that, unlike normal mode, it can no longer revisit a cell once it has been written (and its strings are stored inline rather than de-duplicated, so the file can be slightly larger). Normal mode keeps the whole workbook in memory, which is what lets you write cells in any order and re-style them before saving.
xlswriter is a PHP C Extension for Excel 2007+ XLSX files. It writes text, numbers, formulas, dates, charts, images and hyperlinks to new workbooks, opens existing files to edit them and save the result, reads their contents back, and evaluates formulas to a computed value. It supports features such as:
Both install methods below build from source, so the zlib development headers must be present first (they are often missing on minimal images):
# Debian / Ubuntu
apt-get install -y zlib1g-dev
# Alpine
apk add zlib-dev
# RHEL / CentOS / Fedora
yum install -y zlib-devel
Then install with either PECL or PIE:
PECL
pecl install xlswriter
PIE
PIE also builds from source and additionally needs
the autotools build chain (autoconf, make, a compiler and libtool). It can
install those missing build tools for you with --auto-install-build-tools, but
it cannot install zlib β make sure the headers above are in place first:
pie install --auto-install-build-tools viest/xlswriter
Test environment: Macbook Pro 13 inch, Intel Core i5, 16GB 2133MHz LPDDR3 Memory, 128GB SSD Storage.
Two memory modes export 1 million rows of data (27 columns, data is string)
1 million rows of data (1 columns, data is inter)
Includes extensive and detailed instructions that make it easy to get started with xlswriter.
composer require viest/php-ext-xlswriter-ide-helper:dev-master
This project exists thanks to all the people who contribute. [Contribute].
Become a financial contributor and help us sustain our community. [Contribute]
Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]
BSD License
44 followers Β· starred Mar 2023
58 followers Β· starred Mar 2024
72 followers Β· starred May 2026
6 followers Β· starred Nov 2017