easyexcel icon indicating copy to clipboard operation
easyexcel copied to clipboard

属性大小写会影响数据获取吗?数据丢失

Open AxinGitHub opened this issue 3 years ago • 3 comments

try { response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 String fileName = URLEncoder.encode("导出离线数据", "UTF-8").replaceAll("\\+", "%20"); response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); // 这里需要设置不关闭流 EasyExcel.write(response.getOutputStream(), TicketOff.class).autoCloseStream(Boolean.FALSE).sheet("sheet").doWrite(pagelist.getList()); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("下载报表异常"); }

image image

image

AxinGitHub avatar Aug 04 '22 11:08 AxinGitHub

变量名不会影响数据写入,有可复现demo吗?

juzi214032 avatar Aug 06 '22 12:08 juzi214032

下载地址:https://tutuwp.lanzouj.com/iiM6A096ueoj 运行后,访问地址;http://localhost:9991/domo/api/downloadFailedUsingJson

AxinGitHub avatar Aug 08 '22 04:08 AxinGitHub

参考该issue:https://github.com/alibaba/easyexcel/issues/1467

3.x 版本已修复该bug,升级即可解决

juzi214032 avatar Aug 09 '22 15:08 juzi214032

@juzi214032 3.1.1并没有解决,现在只要属性名为类似aName,用IDEA自带的Getter Setter生成,依然无法导出数据。

cheng6563 avatar Oct 18 '22 08:10 cheng6563

建议改成驼峰形式。 aName 这个get set 有争议 ,你可以试下lombok 和 idea生成的 get set 方法不一样,我们采用了lombok的

zhuangjiaju avatar Feb 08 '23 13:02 zhuangjiaju