Bug 57517 - [PATCH] Wrong result when calling HSSFOptimiser.optimiseCellStyles on workbook that uses user defined styles
Summary: [PATCH] Wrong result when calling HSSFOptimiser.optimiseCellStyles on workboo...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.11-FINAL
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords: APIBug, PatchAvailable
Depends on:
Blocks:
 
Reported: 2015-01-31 00:41 UTC by Akira Shiratsuki
Modified: 2017-11-05 20:34 UTC (History)
1 user (show)



Attachments
Renumber parent indexes and Synchronized StyleRecord with ExFormats. (6.46 KB, patch)
2015-01-31 01:31 UTC, Akira Shiratsuki
Details | Diff
Renumber parent indexes and Synchronized StyleRecord with ExFormats. I modified it morely. ColumnStyle RowStyle only used cell style is preserved. (9.10 KB, patch)
2015-01-31 09:06 UTC, Akira Shiratsuki
Details | Diff
I modified my regression bug. (9.24 KB, patch)
2015-02-12 22:24 UTC, Akira Shiratsuki
Details | Diff
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. (9.70 KB, patch)
2015-02-14 15:59 UTC, Akira Shiratsuki
Details | Diff
test case (5.51 KB, text/x-java)
2015-02-14 16:03 UTC, Akira Shiratsuki
Details
input file (4.50 KB, application/vnd.ms-excel)
2015-02-14 16:10 UTC, Akira Shiratsuki
Details
bad output file (4.50 KB, application/vnd.ms-excel)
2015-02-14 16:11 UTC, Akira Shiratsuki
Details
Test case (5.96 KB, text/x-java)
2015-02-15 00:50 UTC, Akira Shiratsuki
Details
Input file. (Test case write this file. Before calling HSSFOptimiser.optimiseCellStyles .) (5.00 KB, application/vnd.ms-excel)
2015-02-15 00:51 UTC, Akira Shiratsuki
Details
Correct result file. (Test case write this file. After calling HSSFOptimiser.optimiseCellStyles .) (4.50 KB, application/vnd.ms-excel)
2015-02-15 00:53 UTC, Akira Shiratsuki
Details
Bad result file. (Test case write this file. After calling HSSFOptimiser.optimiseCellStyles .) (4.50 KB, application/vnd.ms-excel)
2015-02-15 00:55 UTC, Akira Shiratsuki
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Akira Shiratsuki 2015-01-31 00:41:16 UTC
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.
Comment 1 Akira Shiratsuki 2015-01-31 00:43:45 UTC
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.
Comment 2 Akira Shiratsuki 2015-01-31 01:31:39 UTC
Created attachment 32415 [details]
Renumber parent indexes and Synchronized StyleRecord with ExFormats.
Comment 3 Akira Shiratsuki 2015-01-31 09:06:24 UTC
Created attachment 32416 [details]
Renumber parent indexes and Synchronized StyleRecord with ExFormats.
I modified it morely. ColumnStyle RowStyle only used cell style is preserved.
Comment 4 Akira Shiratsuki 2015-01-31 09:17:25 UTC
http://apache-poi.1045710.n5.nabble.com/Bug-with-HSSFOptimiser-cellStyles-td5711520.html

There is same case I distiguished.
Comment 5 Akira Shiratsuki 2015-02-12 22:24:47 UTC
Created attachment 32466 [details]
I modified my regression bug.
Comment 6 Akira Shiratsuki 2015-02-14 15:59:54 UTC
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.
Comment 7 Akira Shiratsuki 2015-02-14 16:03:27 UTC
Created attachment 32475 [details]
test case
Comment 8 Akira Shiratsuki 2015-02-14 16:10:58 UTC
Created attachment 32476 [details]
input file
Comment 9 Akira Shiratsuki 2015-02-14 16:11:40 UTC
Created attachment 32477 [details]
bad output file
Comment 10 Akira Shiratsuki 2015-02-15 00:50:18 UTC
Created attachment 32478 [details]
Test case
Comment 11 Akira Shiratsuki 2015-02-15 00:51:58 UTC
Created attachment 32479 [details]
Input file. (Test case write this file. Before calling HSSFOptimiser.optimiseCellStyles .)
Comment 12 Akira Shiratsuki 2015-02-15 00:53:16 UTC
Created attachment 32480 [details]
Correct result file. (Test case write this file. After calling HSSFOptimiser.optimiseCellStyles .)
Comment 13 Akira Shiratsuki 2015-02-15 00:55:20 UTC
Created attachment 32481 [details]
Bad result file. (Test case write this file. After calling HSSFOptimiser.optimiseCellStyles .)
Comment 14 Dominik Stadler 2017-11-05 20:34:41 UTC
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.