您的位置:首页 > 大数据 > 人工智能

解决异常:Package should contain a content type part [M1.13]

2015-01-04 16:25 375 查看
 上午遇到个问题
org.apache.poi.POIXMLException: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13]

看了下源码public static Workbook create(InputStream in) throws
IOException,InvalidFormatException {
if (!in.markSupported()) {
in = new PushbackInputStream(in, 8);
}
if (POIFSFileSystem.hasPOIFSHeader(in)) {
return new HSSFWorkbook(in);
}
if (POIXMLDocument.hasOOXMLHeader(in)) {
return new XSSFWorkbook(OPCPackage.open(in));
}
throw new IllegalArgumentException("你的excel版本目前poi解析不了");
}
读写xls和xlsx格式时,HSSFWorkbook针对xls,XSSFWorkbook针对xlsx

格式的问题!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  异常 poi
相关文章推荐