Bug 66675 - Save not happening in work book showing A part with the name '/docProps/core.xml' already exists
Summary: Save not happening in work book showing A part with the name '/docProps/core....
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 5.2.3-FINAL
Hardware: PC All
: P1 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-30 05:34 UTC by Prabhakaran
Modified: 2023-08-01 08:35 UTC (History)
0 users



Attachments
This attachment shows the error (32.00 KB, image/png)
2023-06-30 05:34 UTC, Prabhakaran
Details
Input file (43.40 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2023-07-05 14:09 UTC, Prabhakaran
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Prabhakaran 2023-06-30 05:34:36 UTC
Created attachment 38595 [details]
This attachment shows the error

Hi
I am using apche poi ooxm-5.2.3 version and i was tried older version also.
I have used apache poi for reading the xlsx sheets and removing the selected tabs that is working fine after deletion the save not happen it throwing the following error.

org.apache.poi.openxml4j.exceptions.InvalidOperationException: A part with the name '/docProps/core.xml' already exists : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names. [M1.12]
	at org.apache.poi.openxml4j.opc.OPCPackage.addPackagePart(OPCPackage.java:947)
	at org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:547)
	at org.apache.poi.openxml4j.opc.OPCPackage.save(OPCPackage.java:1496)
	at org.apache.poi.ooxml.POIXMLDocument.write(POIXMLDocument.java:227)
	at com.simplilearn.mavenexample.Authentication.getWorkbook(Authentication.java:691)
	at com.simplilearn.mavenexample.Authentication.exportToFile(Authentication.java:656)
	at com.simplilearn.mavenexample.App.main(App.java:29)

So as per my understanding whenever edit happens using the apche poi it try to create new OPC package part  checks existing part so that time the error displayed.

For testing purpose i have deleted the package part then it was allowed for SAVE.

The JAVA code is pretty straight forward.

try {
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		XSSFWorkbook testWorkBook = new XSSFWorkbook(inputfile);
		testWorkBook.removeSheetAt(0);
		testWorkBook.write(bos);
		}
		catch(Exception e) {
			e.printStackTrace();
		}

Observations:
1.Once opened XLSX even without change also not allowed for save
2.The part name removal working only for windows Environment not LINUX server
Comment 1 PJ Fanning 2023-07-03 19:51:00 UTC
That code is not a test case - where does inputFile param come from? You will need to provide the file.
Comment 2 Prabhakaran 2023-07-05 14:09:17 UTC
Created attachment 38596 [details]
Input file
Comment 3 Prabhakaran 2023-07-05 14:13:52 UTC
Hi please find the attached file,we have developing new POC using apache POI so there is no Test case, this is actual code.

Note:the file directly get it from POWER BI api, if we have download the file  then save as manually after checking it will work properly but our requirement handle the input file dynamically(runtime) so that time i have faced that error.
its not related to file issue
Comment 4 PJ Fanning 2023-07-12 12:30:54 UTC
added r1910949
Comment 5 Prabhakaran 2023-07-20 10:31:40 UTC
Any luck/update?
Comment 6 PJ Fanning 2023-07-20 10:39:31 UTC
have a look at the comment from 2023-07-12 12:30:54 UTC
Comment 7 Dominik Stadler 2023-08-01 08:35:32 UTC
Should be fixed on latest trunk version.