Bug 47090 - Error in "createSheet()" / "cloneSheet()" After "removeSheetAt()"
Error in "createSheet()" / "cloneSheet()" After "removeSheetAt()"
Status: RESOLVED WORKSFORME
Product: POI
Classification: Unclassified
Component: POI Overall
3.5-dev
PC Windows XP
: P2 normal (vote)
: ---
Assigned To: POI Developers List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2009-04-23 21:25 UTC by Yuta Takahashi
Modified: 2013-08-23 18:37 UTC (History)
0 users



Attachments
Test Spreadsheet (7.42 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2009-04-23 21:25 UTC, Yuta Takahashi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yuta Takahashi 2009-04-23 21:25:23 UTC
Created attachment 23534 [details]
Test Spreadsheet

I encountered the following errors when I use "createSheet()" / "cloneSheet()" after "removeSheetAt()". The test spreadsheet is a .xlsx file which has two blank sheets.


Case 1
===============
    Workbook workbook = WorkbookFactory.create(new FileInputStream("Book1.xlsx"));
    workbook.removeSheetAt(0);
    workbook.createSheet();

 Error: java.lang.IllegalArgumentException: The workbook already contains a sheet of this name


Case 2 
===============
    Workbook workbook = WorkbookFactory.create(new FileInputStream("Book1.xlsx"));
    workbook.removeSheetAt(1);
    workbook.createSheet();

 Error: org.apache.poi.POIXMLException: org.apache.poi.openxml4j.exceptions.InvalidOperationException: A part with the name '/xl/worksheets/sheet2.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]


Case 3
===============
    Workbook workbook = WorkbookFactory.create(new FileInputStream("Book1.xlsx"));
    workbook.removeSheetAt(0);
    workbook.cloneSheet(0);

 Error: org.apache.poi.POIXMLException: org.apache.poi.openxml4j.exceptions.InvalidOperationException: A part with the name '/xl/worksheets/sheet2.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]


Case 4
===============
    XSSFWorkbook workbook = new XSSFWorkbook();
    workbook.createSheet();
    workbook.removeSheetAt(0);
    workbook.createSheet();

 Error: org.apache.poi.POIXMLException: org.apache.poi.openxml4j.exceptions.InvalidOperationException: A part with the name '/xl/worksheets/sheet1.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]
Comment 1 Dominik Stadler 2013-08-23 18:37:28 UTC
I could not reproduce any of the problems any more with the latest version of POI, Please try with a snapshot build and reopen the bug with an updated testcase if any of the problems persist for you.