Bug 65289 - XSSFWorkbook.cloneSheet leading to save prompt by Excel without any changes done
Summary: XSSFWorkbook.cloneSheet leading to save prompt by Excel without any changes done
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 4.1.2-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-05 14:43 UTC by George Taylor
Modified: 2021-05-05 15:08 UTC (History)
0 users



Attachments
Code to reproduce the issue (866 bytes, text/plain)
2021-05-05 14:43 UTC, George Taylor
Details

Note You need to log in before you can comment on or make changes to this bug.
Description George Taylor 2021-05-05 14:43:51 UTC
Created attachment 37848 [details]
Code to reproduce the issue

Hi, I have the following scenario: I am opening an excel file using POI, perform a cloneSheet operation on the first sheet and save the file under a new name. When opening the newly created file using Excel 365, a save prompt occurs on closing the file, although no changes have been done. The save prompt asks me to save changes that have occurred. 

This is quite annoying for everyone who just wants to look into the file. Also it doesn't make sense and seems to be some kind of bug by POI or Excel. But even if this whould be an Excel bug, it would be great if POI would find a way to prevent it.

This has been tested using a newly created empty file. If you would like to reproduce the observation, you could use the attached class "Test.java". After having let it run you would open the newly created file by Excel - see below - and immediately close it. You would be prompted to save changes.

Prerequisites are an existent folder "c:/temp" and an empty excel file named "test.xlsx" in there. The newly created file will be named "test_copy.xlsx". You may change path and file names according to your suits. You also need at least Java 1.8 and Excel 365.
Comment 1 George Taylor 2021-05-05 15:08:29 UTC
On my attempts to find the cause I could see that when saving the file by Excel afterwards, it is changing the worksheet tag of the new, cloned sheet changing the order and partially the content of the attributes. After the file has been saved by Excel, no prompt will occur any more on closing without changes done. The main difference between the file saved by POI and being saved by Excel afterwards is the content of the "xr:uid" attribute of the worksheet tag. Its been changed by Excel every time the file is saved. I am saying "main" difference because when using one the contents of the "xr:uid"-attribute and transferring it into the original file created by POI, then no prompt will occur on opening and closing the file by Excel. This seems to "repair" the issue somehow. Now, I am trying to find out what this attribute means and how it could be set by POI, so that Excel will behave well.