Files
PhpSpreadsheet/tests
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
..