100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > poi导出excel损坏无法打开

poi导出excel损坏无法打开

时间:2021-07-06 04:17:16

相关推荐

poi导出excel损坏无法打开

使用poi生成excel文件,格式为xlsx。 生成的文件会偶现打不开的情况, 提示如图:

暂时遇到两种情况会提示打不开文件:

1. sheet页里面没内容:处理方式为在空白页添加title行

2. 生成的excel文件可以打开, 但是经过网络传输后无法打开:处理方式在响应头里面添加两个配置。

// filePath生成的excel文件存放路径FileInputStream fis = new FileInputStream(filePath);response.setHeader("Content-Length", fis.available()+""); // 内容长度response.setContentType("application/octet-stream"); // 响应内容格式

依赖:

<dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>3.15</version></dependency><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml-schemas</artifactId><version>3.15</version></dependency><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>3.15</version></dependency>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。