I called HSSFOptimiser for workbook. The workbook has user defined styles. The result is wrong. Because parent style index is miss matching. And user defined style is miss matching. This arise when user defined style and hidden styel is mixing.
I called HSSFOptimiser.optimiseCellStyles for workbook. The workbook has user defined styles. The result is wrong. Because parent style index is miss matching. And user defined style is miss matching. This arise when user defined style and hidden styel is mixing.
Created attachment 32415 [details] Renumber parent indexes and Synchronized StyleRecord with ExFormats.
Created attachment 32416 [details] Renumber parent indexes and Synchronized StyleRecord with ExFormats. I modified it morely. ColumnStyle RowStyle only used cell style is preserved.
http://apache-poi.1045710.n5.nabble.com/Bug-with-HSSFOptimiser-cellStyles-td5711520.html There is same case I distiguished.
Created attachment 32466 [details] I modified my regression bug.
Created attachment 32474 [details] Synchoronized XF Record with style record. Adjust parent index of XF Record for deleted record. Don't delete style record. It's bultin style or user style. And start off from index(16) of style XF record. Delete unused duplicated style at one time.
Created attachment 32475 [details] test case
Created attachment 32476 [details] input file
Created attachment 32477 [details] bad output file
Created attachment 32478 [details] Test case
Created attachment 32479 [details] Input file. (Test case write this file. Before calling HSSFOptimiser.optimiseCellStyles .)
Created attachment 32480 [details] Correct result file. (Test case write this file. After calling HSSFOptimiser.optimiseCellStyles .)
Created attachment 32481 [details] Bad result file. (Test case write this file. After calling HSSFOptimiser.optimiseCellStyles .)
Thanks for the suggested patch. The optimise-method had some more shortcomings which became apparent when separating the many different things from the test-case into smaller, more narrowed-down test-cases. I re-did the changes in a somewhat different way, trying to handle some more cases/situations correctly. All the things detected by the given tests should be fixed now via r1814373, please report additional bugs for anything that is still not working fine now.