Bug 60197 - setSheetOrder doesn't update names scope
Summary: setSheetOrder doesn't update names scope
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: 3.15-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-03 15:06 UTC by Aurelien JOLY
Modified: 2016-10-09 03:06 UTC (History)
1 user (show)



Attachments
Java test case (8.07 KB, application/x-rar)
2016-10-03 15:06 UTC, Aurelien JOLY
Details
Java test case (1.75 KB, text/x-java)
2016-10-08 23:56 UTC, Javen O'Neal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aurelien JOLY 2016-10-03 15:06:50 UTC
Created attachment 34321 [details]
Java test case

When setSheetOrder is called, and a sheet is moved, the scope of the name in the document stays on the old sheet.

Ex :
 I have document with 3 sheets. I have defined a name on sheet3, when I move sheet3 using setSheetOrder, the scope of the name is still the third sheet which is now sheet2

cf attachement for the reproduction case
Comment 1 Javen O'Neal 2016-10-08 23:56:28 UTC
Created attachment 34343 [details]
Java test case

Could you please attach D:\\testPOI.xlsx to this bug so that we can reproduce this problem?

If this is not possible due to proprietary information, could you either manually create an Excel file that demonstrates the problem or write the unit test to create a new workbook, add the named ranges, change the sheet order, and verify that the named ranges refer to the correct sheets.
Comment 2 Javen O'Neal 2016-10-09 00:00:31 UTC
Disregard comment 1. testPOI.xlsx is the output file name. The test case creates an empty workbook, adds sheets and a named range, changes sheet order, and checks whether the named range refers to the correct sheet.
Comment 3 Javen O'Neal 2016-10-09 03:06:55 UTC
Thanks for finding this bug. I have fixed this bug, with unit tests, for HSSF, XSSF, and SXSSF in r1763939.

While fixing this, I noticed another quirk in XSSF, as documented in the unit test. XSSFName objects become invalid after writing a workbook. If this is an issue for you, please open a new bug if you cannot find an already-open bug for this.