社区
Web 开发
帖子详情
poi读取word文档时报Package should contain a content type part [M1.13]错误
goodfrind123
2017-05-04 11:04:41
...全文
1085
回复
打赏
收藏
poi读取word文档时报Package should contain a content type part [M1.13]错误
[图片]
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
Java使用
POI
技术导出
Word文档
,报错
Package
should
contain
a
content
type
part [
M1
.
13
]
解决
POI
导出
WORD文档
时报
Package
should
contain
a
content
type
part [
M1
.
13
]
错误
Java之
POI
读取
Excel的
Package
should
contain
a
content
type
part [
M1
.
13
]] with root cause异常问题解决
引言: 在Java中,使用
POI
来进行excel的
读取
和解析是常用的一种做法;在office的excel中存在2007,2003两种不同的格式,通常情况下是以xls/xlsx的不同后缀来区分的,但用户可能不知道这个区别,所以会出现格式无法兼容的异常
Package
should
contain
a
content
type
part [
M1
.
13
]
用
POI
导入xls格式的excel正常,xlsx格式的文件报错:
Package
should
contain
a
content
type
part [
M1
.
13
] Workbook workbook = null; String fileName = fileFileName; if (fileName.endsWith(XLS)) { // 2003 workbook ...
java使用
POI
操作word异常InvalidFormatException:
Package
should
contain
a
content
type
part [
M1
.
13
]
1.当出现如下异常时 org.apache.
poi
.openxml4j.exceptions.InvalidFormatException:
Package
should
contain
a
content
type
part [
M1
.
13
] 这是因为使用的word模版的名称有问题, word模版名称可能包含中划线. 例如: xxx-合同.docx,
poi
无法识别中划线. 若必须要加以区分某某文件可以使用下划线,像: xxx_合同书.docx. 2.当使用
poi
在有${name}这种形式变量的
解决异常:
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); }
Web 开发
81,092
社区成员
341,716
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章