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]
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.