Apache POI 是否有 Scala 包装器?
我想使用 Apache POI 在 Scala 应用程序中读取/创建 Excel 文件。当然,我可以直接使用 POI 库,毕竟它是 Java,但我想要有 Scala 的感觉。那么是否有一个 Scala 包装器带来 Scala 的感觉(使用隐式转换),即某种免费提供的“Scala-POI-DSL”?
I would like to use Apache POI to read/create Excel files in an Scala app. Sure, I can use the POI library directly, it's Java after all, but I would like to have the Scala feel. So is there a Scala wrapper bringing the Scala feel (using implicit conversions), i.e. some kind of "Scala-POI-DSL" freely available?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
感谢 Dave Griffith 的回答,我已经破解了类似于他的 DSL 的东西。
代码可以在此处找到。
Thanks to Dave Griffith's answer, I've hacked something similar to his DSL.
Code can be found here.
鉴于 Scala 缺乏先进的开源电子表格包装器,我开始开发 Spoiwo:https://github.com/诺伯特-拉迪克/spoiwo。它允许生成 XSSFWorkbook 并支持 POI 功能的重要子集。
它仍然需要一些文档,但下面应该给出关于其功能的粗略了解:
使用 Spoiwo 的简单电子表格示例:
Given the lack of advanced, open source spreadsheet wrappers for Scala, I've started the development of Spoiwo: https://github.com/norbert-radyk/spoiwo. It allows the generation of the XSSFWorkbook and supports a significant subset of POI's functionality.
It still requires a bit of documentation, but the below should give a rough idea about its capabilities:
The example of simple spreadsheet using Spoiwo:
Fancy POI - 似乎找不到太多信息,但我想这就是你正在寻找的为了。
Fancy POI - Not much info to be found it seems but I guess it is what you're looking for.
这完全没有帮助,但我为 POI 编写了一个类似 Scala 的 DSL。它允许像这样的代码
可悲的是,如果没有与我的老板核实,我就无法将其发布,但说实话,这并不难做到。您应该能够毫不费力地从该示例中对大部分内容进行逆向工程。
This is utterly unhelpful, but I hacked up an Scala-ish DSL for POI. It allows code like
Sadly I can't give it out without checking with my boss, but to be honest it wasn't that hard to do. You should be able to reverse-engineer most of it from that example without much trouble.
如果您正在编写 Office XML,则可以考虑避免使用 POI 并直接创建 XML(并将其一起归档)。对于简单的电子表格来说,做起来非常简单,并且消除了很多变量。
请注意,通过 POI 的 OOXML 支持,如果您打算创建大型电子表格(超过 65k 行),则需要使用其流模式。
If you're writing Office XML, you could consider avoiding POI and creating the XML directly (plus archiving it together). For simple spreadsheets it's pretty simple to do it, and you're eliminating a lot of variables.
Note that with POI's OOXML support you'll need to use its streaming mode if you intend to create large spreadsheets (greater than 65k rows).
我不知道有任何 Scala 库可以进行这种封装。
关于使用 apache POI 的大多数问题都是关于迭代器。
alex Cheng 项目可以导入 Excel 文档,并且有一个 测试用例。
但仅此而已。
I don't know of any Scala library for this kind of encapsulation.
Most questions around using apache POI are about iterators.
And the alexcheng project does import an Excel document, and has a test case.
But that's about it.