alibaba/easyexcel

不会过滤尾部空行

Open

#4,009 opened on Sep 26, 2024

View on GitHub
 (2 comments) (0 reactions) (2 assignees)Java (7,599 forks)batch import
help wanted

Repository metrics

Stars
 (33,728 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

建议先去看文档 设置ignoreEmptyRow(false)

触发场景描述 请求一个服务内部接口(该接口实现从阿里oss下载文件),会获得ResponseEntity<byte[]> 开启不忽略空行ignoreEmptyRow(false), 数据格式: 行1 111 行2 222 行3 333 行4 444 行5 555 行6-行10后面都是空行(以前有过填写,后面进行清空内容) 这时候我会校验这里有是否有空行,有就抛出异常,但是校验出行6一直到行10都是空行。 wps操作的清除内容不会校验出行6到行10是空行,office操作的清除内容会校验出。 删除行两个软件都不会校验出6到行10是空行

触发Bug的代码 ResponseEntity<byte[]> responseEntity = FeignClient() ByteArrayInputStream inputStream = new ByteArrayInputStream(responseEntity.getBody()); public void invoke(ImportTerminalDto importTerminalDto, AnalysisContext analysisContext) { // log.info("解析到第 {} 行数据: {}", rowIndex, importTerminalDto.getCode()); String data = String.valueOf(importTerminalDto.getCode()); rowIndex++; if ("null".equals(data) || data == null || data.trim().isEmpty()) { terminalNull.add(rowIndex); whetherRedis = false; }

提示的异常或者没有达到的效果 尾部空行没有进行过滤

Contributor guide