We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
查看源码,定义了SingleSheetWriteHandler和ManySheetWriteHandler来进行相应导出操作,里面的support方法来判断使用哪一个类。由于数据长度为零,两次support调用都返回false,导致没有文件导出。
SingleSheetWriteHandler
ManySheetWriteHandler
support
数据为空时不进行导出,不太符合一般的业务逻辑,这种情况下导出空的文件更符合预期。希望维护者能更新这一块的逻辑,或让用户通过参数自定义导出行为。
如果想临时修改这部分逻辑,可以实现自定义的SingleSheetWriteHandler,修改默认support实现。
代码示例
@Component public class MySingleSheetWriteHandler extends SingleSheetWriteHandler { public MySingleSheetWriteHandler(ExcelConfigProperties configProperties, ObjectProvider<List<Converter<?>>> converterProvider, WriterBuilderEnhancer excelWriterBuilderEnhance) { super(configProperties, converterProvider, excelWriterBuilderEnhance); } @Override public boolean support(Object obj) { if (obj instanceof List) { List<?> objList = (List<?>) obj; if (objList.isEmpty()) { return true; } return !(objList.get(0) instanceof List); } else { throw new ExcelException("@ResponseExcel 返回值必须为List类型"); } } }
The text was updated successfully, but these errors were encountered:
如果为空的话,此时无法读取到第一行的具体标题
Sorry, something went wrong.
这个时候返回一个空的文件比什么都不做更符合预期
No branches or pull requests
问题说明
查看源码,定义了
SingleSheetWriteHandler
和ManySheetWriteHandler
来进行相应导出操作,里面的support
方法来判断使用哪一个类。由于数据长度为零,两次support
调用都返回false,导致没有文件导出。数据为空时不进行导出,不太符合一般的业务逻辑,这种情况下导出空的文件更符合预期。希望维护者能更新这一块的逻辑,或让用户通过参数自定义导出行为。
临时解决方法
如果想临时修改这部分逻辑,可以实现自定义的
SingleSheetWriteHandler
,修改默认support
实现。代码示例
The text was updated successfully, but these errors were encountered: