Bug 59671

Summary: Exception while updating XLSX file
Product: POI Reporter: Badari <badbadri>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: Simple xlsx file with a few columns

Description Badari 2016-06-07 17:18:11 UTC
Created attachment 33923 [details]
Simple xlsx file with a few columns

Exception in thread "main" org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Rule M2.4 exception : this error should NEVER happen! Please raise a bug at https://bz.apache.org/bugzilla/enter_bug.cgi?product=POI and attach a file that triggers it, thanks!
  at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.getContentType(ContentTypeManager.java:343)
  at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.removeContentType(ContentTypeManager.java:256)
  at org.apache.poi.openxml4j.opc.OPCPackage.removePart(OPCPackage.java:943)
  at org.apache.poi.openxml4j.opc.PackagePart.getOutputStream(PackagePart.java:522)
  at org.apache.poi.xssf.usermodel.XSSFWorkbook.commit(XSSFWorkbook.java:1678)
  at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:341)
  at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:206)
  at com.geni.common.ExcelUpdater.updateXLSX(ExcelUpdater.java:75)
  at UpdateXLSX.main(UpdateXLSX.java:16)
Comment 1 Badari 2016-06-07 17:22:01 UTC
The exception is raised when the method is called more than once

// Temp.xlsx is output file. Input file is always "EDIStatsTemplate.xlsx"

ExcelUpdater excelUpdater = new ExcelUpdater("Temp.xlsx");
int txns = 44;
excelUpdater.updateXLSX(new Object[] { "X12", "856", "4010", "LG", txns });
txns = 54;
excelUpdater.updateXLSX(new Object[] { "X12", "856", "4010", "LG", txns });
Comment 2 Badari 2016-06-07 17:38:39 UTC
Apologies. I closed the output file prematurely but tried to update. That caused the exception.