寻找JasperReports的替代品 [英] Looking for an alternative to JasperReports

查看:1298
本文介绍了寻找JasperReports的替代品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前一天,我的老板问我,他想从网络应用程序中获取PDF格式的发票。鉴于每个人都使用JasperReports和iReport进行设计,我试过了。我的Web应用程序基于Java + Hibernate和Spring。起初Jasper看起来很好,而iReport也是如此。无论如何,我被两件事所阻止:

Some day ago my boss asked me that he wanted invoices in PDFs from out web application. Given that everybody uses JasperReports and iReport for design I tried it. My web app is based on Java+Hibernate and Spring. At the beginning Jasper seemed fine and iReport too. Anyway I've been stopped by two things:


  • iReport是我生命中见过的最慢的东西。

  • 更严重的是,我确定某些类具有一些类层次结构,并且在Jasper中处理它非常复杂。我办公室里的每个人都使用带有SQL查询的Jasper,这样它就是一个简单而方便的工具,但我花了一整天的时间尝试将我的bean映射到报告和子报告以及很少的工作。

我见过DynamicJasper,但似乎我无法用它设计报告。你怎么看?是否有更容易使用的替代品?

I've seen DynamicJasper, but, it seems that I can't design reports with it. What do you think? Are there easier to use alternatives?

推荐答案

如果时间紧迫(通常是老板递给你的东西) )我建议查看 iText (主要网站是这里)。

If time is of the essence (as is usually the case when your boss hands you something) I would recommend checking out iText (main site is here).

学习非常非常简单(您可以在20分钟内完成,运行并生成简单的Hello,PDF!示例),并且可以将任何内容导出为PDF:表,列表,图表,图像,超文本等。

It is very, very simple to learn (you can have it up, running, and generating simple "Hello, PDF!" examples in 20 minutes) and can export just about anything into PDF: tables, lists, charts, images, hypertext, etc.

我自己承认,实现其 JRBeanCollectionDataSource 的JasperReports是为您提供更优雅,灵活,永久的解决方案。但是如果你需要一个快速脏的库来生成PDF,迫在眉睫的截止日期即将到来,我会下载iText JAR并拥有它。

By my own admission, JasperReports implementing its JRBeanCollectionDataSource is a more elegant, flexible, permanent solution for you. But if you need a quick-n-dirty library to just produce PDFs, and looming deadlines are drawing nigh, I would download the iText JAR and have at it.

该网站载有实用的代码示例,几乎可以解决您想要完成的任何事情。

The site is loaded with practical code examples for just about anything you would want to accomplish.

与JasperReports不同,iText不是报告生成器。它只是一个PDF生成器(从我在你的问题中可以看出,声音就像你需要的一样)。因此,对于任何特定的Bean,您只需选择要导出到PDF发票的属性,然后使用段落等等,根据需要将它们附加到文档中:

Unlike JasperReports, iText is not a report generator. Its just a PDF generator (which, from what I can tell in your question, sounds like all you need). So, for any particular Bean, you would just select the properties you want exported to the PDF invoice, and use the Chunk, Paragraph, etc. classes to append them to the document as you need:

// Your POJO/Bean/VO
Employee oEmp = new Employee();

Document oInvoicePdf = new Document();
PdfWriter.getInstance(document, new FileOutputStream("/invoices/2011/Invoice201.pdf"));
document.open();
document.add(new Chunk("Employee's name is : " + oEmp.getName()));
document.close();

即使这不是你想要的,不惜一切代价我建议您转向 Apache PdfBox。在我的拙见中,这是纯粹的邪恶,只会伤害你的心。

Even if this is not what you're looking for, at all costs I would recommend you steer clear of Apache PdfBox. In my humble opinion, it is pure evil and will only break your heart.

希望这会有所帮助,祝你好运!

Hope this helps, and best of luck!

这篇关于寻找JasperReports的替代品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆