mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-11-11 04:16:23 +00:00
d438cd1920
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.