用于输出打印格式文本的 Java 库是什么?
我正在开发一个遗留的 Java 程序。我需要以纯 ASCII 格式打印数据报告。
有些数据采用表格形式,这很棘手,因为当列对于页面宽度来说太长时,我需要换行。另外,对于跨多个页面的表格,我需要重新打印表格标题。
我还需要以 CSV 格式导出表格。
此外,我需要以人类可读的 ASCII 格式报告类似树的数据结构。
我四处寻找库,但没有找到任何满足我需求的东西,有人知道有什么好的纯文本布局库吗?
I'm working on a legacy Java program. I need to print out data reports in pure ASCII.
Some of the data is in the form of tables which is tricky because I need to wrap columns when they are too long for the width of the page. Also, for tables that span multiple pages I need to reprint the table headers.
I also need to export tables in CSV.
In addition, I need to report tree-like data structures in human-readable ASCII.
I've looked around for libraries, but haven't found anything that meets my needs, does anyone know of any good plain text layout libraries?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一种解决方案是将数据写入 Java 内存关系数据库(例如 Apache Derby 或 h2database),然后使用标准 Java 报告工具(例如 Jasper Reports)(http://www.jasperforge.org 或 http://www.jaspersoft.com/ ),具有自动换行、页眉、CSV 导出以及许多您可能需要或不需要的其他报告功能。
One solution is to write your data to a Java in-memory relational database such as Apache Derby or h2database and then use a standard Java reporting tool such as Jasper Reports ( http://www.jasperforge.org or http://www.jaspersoft.com/ ) that has word-wrapping, page headers, CSV export and lots of other reporting features you may or may not want.
您看过 Apache FOP 吗?
Have you looked at Apache FOP?
作为一个轻量级出口商,这看起来很有希望。然而,在一些字符串操作库的帮助下手动滚动解决方案可能是最终的解决方案。
http://code.google.com/p/data-exporter/
This looks promising as a light-weight exporter. However, hand-rolling a solution with help from some string manipulation libraries may be the final solution.
http://code.google.com/p/data-exporter/