Created attachment 33394 [details] Program to reproduce this bug. See instructions for reproducing. The same code used for all worksheets produces different results. The first few worksheets look fine but gradually colors drop off until there are no colors at all. To reproduce: Run the attached program with one command-line arg for the output file name. In the generated file, click from left to right on the worksheets. The first two worksheets look fine. The third worksheet has only one row set to blue, and no row set to yellow. The remaining worksheets have no color. Change NUM_COLUMNS from 7 to 3 in the code. Compile and run again. Click from left to right on the worksheets. The first four worksheets look fine. The fifth worksheet only has yellow on the first column. The sixth worksheet has no color. Using poi version 3.13. Same behavior with 3.12.
Styles are per Workbook and should be reused across cells, does it work when you just use two global styles across the workbook?
That was it. My mistake. Thank you! When creating styles for each cell, they're separate objects, so it's odd that they don't wind up with the same effect on each worksheet (is that a bug?).
That fixed it. Any idea why repeatedly creating cell styles would cause them to stop applying colors as defined? Also, when defining styles to be used globally, the API supports defining a user string for the style, but there's no way to look up a style by string, so the styles have to be passed as additional parameters, or assigned to globals. It would be nice to be able to look up by name.
Glad that it helped, I quickly tried it locally on Linux, LibreOffice shows the colors in the resulting file correctly, so it seems to be some strange behaviour with Excel. Anyway I don't see anything that we can fix here so I am closing this for now.