Bug 49222 - Cant read odt file created in both OpenOffice 3.2 and MicrosoftOffice2007
Summary: Cant read odt file created in both OpenOffice 3.2 and MicrosoftOffice2007
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 3.6-FINAL
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-29 10:49 UTC by macio
Modified: 2010-04-30 07:28 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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