在java中打印简单报告的最佳方式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3213871/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 17:28:37  来源:igfitidea点击:

Best way of printing simple reports in java

javareport

提问by Myth

I have developed a Java application and now i want to give some simple printing support. Something like printing invoices , some reports etc. Right now I'm creating that stuff in html, showing it on JEditorPane. but html support is quite poor and I'm really fade up of that thing. Is there any better way of doing such thing? Any better browser component, or better tool to create such simple reports? (JDK 1.6)

我已经开发了一个 Java 应用程序,现在我想提供一些简单的打印支持。像打印发票,一些报告等。现在我正在用 html 创建这些东西,在 JEditorPane 上显示它。但是 html 支持很差,我真的对那件事淡化了。有没有更好的方法来做这样的事情?有没有更好的浏览器组件,或者更好的工具来创建这样简单的报告?(JDK 1.6)

采纳答案by Pablo Santa Cruz

I love JasperReportsfor that. In combination with iReport (a GUI for creating the reports) is the best I could find for free in Java to do reporting.

我喜欢JasperReports。结合 iReport(用于创建报告的 GUI)是我能在 Java 中免费找到的最好的报告。

You can also generate PDFs files with iTextfor printing. Although I think it will be easier to use iReports.

您还可以使用iText生成 PDF 文件以进行打印。虽然我认为使用 iReports 会更容易。

回答by Edward Dale

JasperReportsis a pretty nice reporting tool for Java. It could be a bit heavy weight for what you want.

JasperReports是一个非常好的 Java 报告工具。对于你想要的东西,它可能有点重。

回答by Benoit Courtine

Another solution is BIRTwhich is very simple to use : it is an Eclipse project with a visual editor for your reports. The report is built in 3 steps :

另一个解决方案是BIRT,它使用起来非常简单:它是一个 Eclipse 项目,带有用于您的报告的可视化编辑器。该报告分为 3 个步骤:

  • create a DataSource
  • create a DataSet on this DataSource
  • create your report, based on the DataSet
  • 创建数据源
  • 在此数据源上创建一个数据集
  • 根据数据集创建您的报告

回答by Ricardo

DynamicReportsis an open source reporting tool. You can create reports quickly without needing to use a visual designer. See the examples.

DynamicReports是一个开源报告工具。您无需使用可视化设计器即可快速创建报告。请参阅示例

回答by Paul Jowett

When printing invoices and reports, no doubt you want them to look more than basic - hence your problem. If your swing application has a server-side component, then look at libraries like Jasper and Docmosisto produce decent reports from the server (since heavy-weight server side is typically aok). If you really need a library just for a client app, there's an old library called JViewProwhich is pretty yuk to code with, but can let you layout reports in code for displaying and printing and is a single jar (just be careful about memory usage).

打印发票和报告时,毫无疑问您希望它们看起来不仅仅是基本的 - 这就是您的问题。如果您的 Swing 应用程序具有服务器端组件,那么查看 Jasper 和Docmosis等库以从服务器生成不错的报告(因为重量级服务器端通常是可以的)。如果您真的需要一个仅用于客户端应用程序的库,那么有一个名为JViewPro的旧库,它非常适合编写代码,但可以让您在代码中布局报告以进行显示和打印,并且是一个单独的 jar(请注意内存使用情况) )。