-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
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
[add] direct Stream support as read output #3052
base: master
Are you sure you want to change the base?
Conversation
hi,为了保持与原版一致,支持多种数据源与sheet设置,我又提交了一版代码,应该达到可发布的状态了 // 根据路径读取全部sheet
Stream<DemoData> stream1 = EasyExcel.read("file", DemoData.class).toStream();
// 从文件对象读取与第一个sheet
Stream<DemoData> stream2 = EasyExcel.read(new File("file"), DemoData.class).toStream(0);
// 从InputStream读取指定名字sheet
Stream<DemoData> stream3 = EasyExcel.read(Files.newInputStream(Paths.get("file")), DemoData.class).toStream("Sheet1"); |
你这个流没法limit把 |
直接是没法limit,但要加也简单,加个int参数带进去就行 |
感觉可以定义为一种新的接口继承Consumer<BiConsumer<T, AnalysisContext>>>返回,提供一些流式操作的默认方法,这样既不会丢失行信息,也可以避免用户的一些非法操作 |
嗯,相当于一个简单版的callback流,提供常用操作就好,limit也能实现。 |
合并为啥被阻止了呢, 正想着自己封装不好呢, 官方也不提供, 好不容易看到一个符合需求的还被拒绝合并了 |
官方摆烂很久了 |
Great improvement! This seems to be a highly requested feature. I’ll spend some time researching it and will discuss with other project members whether to implement this request (I personally think this feature is interesting as it could help light users focus more on the business code itself). I’ll update the status of this issue and share updates promptly. 很好的PR!我将和其他开发人员讨论是否要增加类似的功能。我会及时修改这个 PR 的状态和更新消息。 |
都停更了也没消息 |
给EasyExcel添加直接的
Stream
支持,不加入任何中间缓存用户不需要创建匿名
ReadListener
类,甚至不需要感知它的存在读取Excel的过程直接转化为流式API,也就是
Stream
,之后可以随意聚合为List
,Map
或者进行别的任何操作整个封装没有任何额外性能或内存开销,甚至连原本
PageReadListener
里的cachedDataList
也省了这一版提交没有处理
sheet()
等相关可选操作,仅作为原理展示新增的方法本身是static函数,所以可以随意复制到本地进行测试