Bug 59639 - org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException
Summary: org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-27 10:25 UTC by ankita
Modified: 2016-10-19 08:11 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ankita 2016-05-27 10:25:14 UTC
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:958)
	at org.apache.poi.openxml4j.opc.PackagePart.getOutputStream(PackagePart.java:522)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.commit(XSSFWorkbook.java:1687)
	at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:464)
	at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:211)
	at AddPatient_Excel.ReadPatientExcel.writeExcel(ReadPatientExcel.java:110)
	at AddPatient_Excel.ReadPatientExcel.fillPatientDetails(ReadPatientExcel.java:94)
	at AddPatient_Excel.ReadPatientExcel.readPatientExc(ReadPatientExcel.java:65)
	at AddPatient_Excel.ReadPatientExcel.main(ReadPatientExcel.java:35)
Comment 1 Dominik Stadler 2016-05-27 19:26:34 UTC
What about "and attach a file that triggers it"? Without it there is not much we can do...
Comment 2 ankita 2016-05-30 10:22:19 UTC
(In reply to Dominik Stadler from comment #1)
> What about "and attach a file that triggers it"? Without it there is not
> much we can do...

Following method is generating issue:
It is Write On Excel file

public void writeMethod() throws FileNotFoundException, IOException{
			
			String dataToWrite[]={"Pass"};	
			//FileInputStream inputStream=new FileInputStream("C:\\Users\\Ankita.Naik\\workspace\\Selenium_Practice\\src\\AddPatient_Excel\\A.xlsx");
					
			XSSFWorkbook workbook=new XSSFWorkbook(new FileInputStream("C:\\Users\\Ankita.Naik\\workspace\\Selenium_Practice\\src\\AddPatient_Excel\\A.xlsx"));
			XSSFSheet sheet=workbook.getSheetAt(0);
			int rowcount=sheet.getLastRowNum()-sheet.getFirstRowNum();
			
			//Row row=sheet.getRow(0);
			//Row newRow=sheet.createRow(rowcount+1);
			
			for(int i=0;i<rowcount;i++)
				{
					Row row=sheet.getRow(i);
					Cell cell=row.createCell(3);
					cell.setCellValue(dataToWrite[i]);
				}
			
			workbook.close();
			FileOutputStream outputStream=new FileOutputStream("C:\\Users\\Ankita.Naik\\workspace\\Selenium_Practice\\src\\AddPatient_Excel\\A.xlsx");
			workbook.write(outputStream);
			outputStream.close();
			
	}
Comment 3 Javen O'Neal 2016-10-19 08:11:01 UTC
Workbook objects cannot be used after they are closed.
From javadocs[1] "Once this has been called, no further operations, updates or reads should be performed on the Workbook."

> workbook.close();
> FileOutputStream outputStream=new FileOutputStream(...);
> workbook.write(outputStream);
> outputStream.close();

[1] https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Workbook.html#close()