Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

php_excel

> 编程语言
Open source

PHP Extension interface to the Excel writing/reading library

600 stars0 likes0 views
WebsiteGitHub

About

PHP Extension interface to the Excel writing/reading library

php_excel

Native C extension for reading and writing Excel files in PHP, powered by LibXL. 7-10× faster than PhpSpreadsheet with substantially lower memory pressure. Full XLS and XLSX support: rich text, conditional formatting, formulas, autofilters, form controls, embedded charts, and structured tables. PHP 8.1+ minimum. 2.0 ground-up modernization shipped April 2026.

Install

Via PIE (PHP Foundation's PECL successor):

bash
pie install iliaal/php-excel \
  --with-libxl-incdir=/path/to/libxl/include_c \
  --with-libxl-libdir=/path/to/libxl/lib64

Or build from source:

bash
phpize
./configure --with-excel \
  --with-libxl-incdir=/path/to/libxl/include_c \
  --with-libxl-libdir=/path/to/libxl/lib64
make
sudo make install

Then add extension=excel.so to your php.ini.

LibXL is a commercial library; download it from libxl.com and point the configure flags at its include_c and lib64 directories.

️ Getting started

…

save() stages the workbook to a temporary sibling file and renames it into place, so a failed save leaves the destination untouched. If the rename fails, local-path saves fail closed (return false); stream wrappers that omit rename() fall back to a direct write with a warning. Failed handle creation and rejected header, footer, font-size, and staging inputs emit warnings naming the cause — suppress with @ only where you handle false explicitly.

Performance

Write 100,000 rows × 20 columns vs PhpSpreadsheet 5.5.0 on PHP 8.4.19 NTS, Apple M3:

Rows Cells php_excel PhpSpreadsheet Speedup
1,000 20K 0.05s / 85 MB 0.45s / 162 MB 10×
10,000 200K 0.55s / 153 MB 4.59s / 282 MB 9×
50,000 1M 2.72s / 508 MB 24.7s / 790 MB 9×
100,000 2M 5.37s / 908 MB 51.1s / 1,415 MB 10×

Read performance is similar: 8-9× faster than PhpSpreadsheet, 3× faster than OpenSpout (with proportional memory tradeoff vs OpenSpout's flat 130 MB streaming model).

For read-heavy import paths, prefer readRow(), readCol(), or readRange() over per-cell read() loops. Pass false for the $read_formula argument when cached values are enough; this avoids the per-cell formula-text probe. For sparse sheets, readSparseRow() and readSparseCol() return only occupied cells keyed by their original column or row indexes.

Why PhpSpreadsheet OOMs and php_excel doesn't

PHP's memory_get_peak_usage() reports about 2 MB for php_excel because LibXL allocates on the C heap, invisible to PHP's memory_limit. PhpSpreadsheet allocates in PHP's memory: it OOMs on 10,000 rows in a default 128 MB PHP-FPM pool. php_excel writes 100,000 rows in the same pool without raising the limit.

That's the practical difference. Bench numbers tell you it's faster; this tells you it's the difference between "report generates" and "report 500s in production."

Classes

Class Description
ExcelBook Workbook management: create, load, save, sheets, fonts, formats, pictures
ExcelSheet Cell read/write, formatting, printing, protection, hyperlinks, data validation
ExcelFormat Cell formatting: colors, borders, number formats, alignment, patterns
ExcelFont Font properties: name, size, bold, italic, underline, color
ExcelAutoFilter AutoFilter operations and sorting
ExcelFilterColumn Filter column criteria
ExcelRichString Mixed-font text in a single cell
ExcelFormControl Form controls: checkboxes, dropdowns, spinners, buttons
ExcelConditionalFormat Conditional formatting style rules
ExcelConditionalFormatting Conditional formatting ranges and rule application
ExcelCoreProperties Workbook metadata: title, author, dates, categories
ExcelTable Structured table support (xlsx)

2.0 added six new classes (ExcelRichString, ExcelFormControl, ExcelConditionalFormat, ExcelConditionalFormatting, ExcelCoreProperties, ExcelTable) plus full arginfo coverage: 399 typed parameters and 277 typed return values across the surface.

php.ini settings

Store LibXL credentials in php.ini instead of source code. The extension reads them automatically when you pass null to the constructor.

ini
[excel]
excel.license_name="YOUR_LICENSE_NAME"
excel.license_key="YOUR_LICENSE_KEY"
excel.skip_empty=0

Native PHP extensions

Companion native PHP extensions:

  • mdparser: native CommonMark + GFM markdown parser via md4c. 15-30× faster than pure-PHP libraries.
  • php_clickhouse: native ClickHouse client speaking the wire protocol directly. Picks up where SeasClick left off.
  • pdo_duckdb: PDO driver for DuckDB, analytical SQL in your PHP stack.
  • fastjson: drop-in faster ext/json, backed by yyjson. 6× encode, 2.7× decode, 5× validate.
  • phpser: decoder-optimized binary serializer for cache workloads. Faster than igbinary on packed numerics and DTO batches.
  • fast_uuid: high-throughput UUID generation (v1/v4/v7), batched CSPRNG and SIMD hex formatter, ramsey-compatible API.
  • fastchart: native chart-rendering extension. 38 chart types behind one fluent OO API, SVG-canonical with PNG/JPG/WebP and optional PDF output.
  • statgrab: system statistics (CPU, memory, disk, network) via libstatgrab, no parsing /proc by hand.
  • phonetic: native phonetic name matching (Double Metaphone, Beider-Morse, Daitch-Mokotoff, NYSIIS, Match Rating), the encoders PHP core lacks.

Read more

Full background, design rationale, and benchmark methodology in the launch post: php_excel 2.0: The C Extension for Excel That PHP Should Have Had All Along.

API reference lives in docs/; usage examples live in tests/.

License

PHP License 3.01. See LICENSE.

LibXL itself is commercial. See libxl.com for licensing.


Follow @iliaa on X • Blog • If this sped up your stack, ⭐ star it!

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Cexcellibxlpeclphp

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言