Sergey Pashkevich d438cd1920 Fix Xls Writer reusing an occupied palette index
Xls files store colors as indexes into a palette that the Writer builds
while it walks the workbook styles. addColor() picked the next custom
index from the most recently inserted entry (end()) instead of the
highest index in use.

A color matching an existing palette entry is cached under its exact RGB
string together with the matched index. When the same color is added
later under a differently-cased key (e.g. `ffffff` after `FFFFFF`), that
old, lower index is appended to the cache and "last used" moves
backwards. The next custom color then reuses and overwrites the palette
slot of an earlier custom color, so e.g. gray text is rendered in the
blue used by a fill.

Base the next index on max() so a custom color never lands on an
occupied palette slot.
2026-09-28 17:12:30 +03:00
2026-09-23 12:26:14 +01:00
…
2026-09-20 16:29:06 -07:00
2026-09-14 07:39:37 -07:00
2026-09-11 03:11:52 -07:00
2026-09-11 03:11:52 -07:00
2026-09-16 20:49:48 -07:00
…
2026-09-19 19:57:45 -07:00
…

PhpSpreadsheet

Build Status Code Coverage Total Downloads Latest Stable Version License Join the chat at https://gitter.im/PHPOffice/PhpSpreadsheet

PhpSpreadsheet is a library written in pure PHP and offers a set of classes that allow you to read and write various spreadsheet file formats such as Excel and LibreOffice Calc.

This is the master branch, and is maintained for security and bug fixes.

PHP Version Support

LTS: For maintained branches, support for PHP versions will only be maintained for a period of six months beyond the end of life of that PHP version. Dropping support for versions after that date will not be considered a breaking change.

Currently the required PHP minimum version is PHP 8.2, and we will support that version until 30th June 2027.

See the composer.json for other requirements.

Installation

See the install instructions.

Documentation

Read more about it, including install instructions, in the official documentation. Or check out the API documentation.

Please ask your support questions on StackOverflow, or have a quick chat on Gitter.

Patreon

I am now running a Patreon to support the work that I do on PhpSpreadsheet.

Supporters will receive access to articles about working with PhpSpreadsheet, and how to use some of its more advanced features.

Posts already available to Patreon supporters:

  • The Dating Game
    • A look at how MS Excel (and PhpSpreadsheet) handle date and time values.
  • Looping the Loop
    • Advice on Iterating through the rows and cells in a worksheet.

And for Patrons at levels actively using PhpSpreadsheet:

  • Behind the Mask
    • A look at Number Format Masks.

The Next Article (currently Work in Progress):

  • Formula for Success
    • How to debug formulae that don't produce the expected result.

My aim is to post at least one article each month, taking a detailed look at some feature of MS Excel and how to use that feature in PhpSpreadsheet, or on how to perform different activities in PhpSpreadsheet.

Planned posts for the future include topics like:

  • Tables
  • Structured References
  • AutoFiltering
  • Array Formulae
  • Conditional Formatting
  • Data Validation
  • Value Binders
  • Images
  • Charts

After a period of six months exclusive to Patreon supporters, articles will be incorporated into the public documentation for the library.

PHPExcel vs PhpSpreadsheet ?

PhpSpreadsheet is the next version of PHPExcel. It breaks compatibility to dramatically improve the code base quality (namespaces, PSR compliance, use of latest PHP language features, etc.).

Because all efforts have shifted to PhpSpreadsheet, PHPExcel will no longer be maintained. All contributions for PHPExcel, patches and new features, should target PhpSpreadsheet master branch.

Do you need to migrate? There is an automated tool for that.

License

PhpSpreadsheet is licensed under MIT.

Languages
PHP 99.8%
HTML 0.2%