Bug 49222

Summary: Cant read odt file created in both OpenOffice 3.2 and MicrosoftOffice2007
Product: POI Reporter: macio <macio77>
Component: XWPFAssignee: POI Developers List <dev>
Status: RESOLVED INVALID    
Severity: normal CC: macio77
Priority: P2    
Version: 3.6-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description macio 2010-04-29 10:49:16 UTC
When I try to open odt file poi throws Exception as follows:
Exception in thread "main" org.apache.poi.POIXMLException: 
org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13]
	at org.apache.poi.util.PackageHelper.open(PackageHelper.java:55)
	at org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:98)
	at pl.macio.WordGenerator.generate(WordGenerator.java:109)
	at pl.macio.WordGenerator.main(WordGenerator.java:87)
Caused by: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13]
	at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:147)
	at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:585)
	at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:201)
	at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:178)
	at org.apache.poi.util.PackageHelper.open(PackageHelper.java:53)
	... 3 more

WordGenerator is my class in which I try to open some odt file:
line 108 is: InputStream fis = new FileInputStream(inFileName);
line 109 is: XWPFDocument doc = new XWPFDocument(fis);

This exception is thrown in fact by ZipPackage.getPartsImpl().
As this method is looking for entry with name ("[Content_Types].xml" - ContentTypeManager.CONTENT_TYPES_PART_NAME), but in files stored in both
OpenOffice and MSOffice there is nothing like this.
Comment 1 Nick Burch 2010-04-30 07:28:49 UTC
POI does not support .odt files, only the Microsoft binary and ooxml file formats

You need to use a different library that supports the open office file formats