java 使用 JasperReports 的最佳方法是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3353983/
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-10-30 01:27:04  来源:igfitidea点击:

What is the best approach to use JasperReports?

javareportingjasper-reportsjasperserver

提问by Amr Faisal

Here we are talking about three main products: JasperReports: which is just a library to generate reports and fill it iReport: which is GUI tool to develop templates used by the above library JasperServer: which is full application with web interface for managing reports with users permissions and other features,

这里我们讨论三个主要产品: JasperReports:它只是一个生成报告并填充它的库 iReport:它是开发上述库使用的模板的 GUI 工具 JasperServer:它是一个完整的应用程序,带有 Web 界面,用于与用户一起管理报告权限和其他功能,

documentation is really not that good, i want to use the best of the above products to integrate JasperReportswith my application (Spring/Hibernate), so please advice what is the best approach to do this,

文档真的不是那么好,我想使用上述产品中最好的来JasperReports与我的应用程序 ( Spring/ Hibernate)集成,所以请建议这样做的最佳方法是什么,

1- design reports using iReportusing embedded sql generation, and make it as a separate project from mine, I tried to use Hibernateor Springwithin iReportbut also I faced a lot of problems and no clear documentation for this part

1-iReport使用嵌入式 sql 生成设计报告,并将其作为独立于我的项目,我尝试使用HibernateSpring在其中使用,iReport但也遇到了很多问题,这部分没有明确的文档

2- attach it with my project, to use same Hibernateconfiguration, already created entities

2- 将它附加到我的项目中,使用相同的Hibernate配置,已经创建的实体

3- try to use JasperServerwhich seems to be complicated, and then expose reports as webservices

3-尝试使用JasperServer看起来很复杂的,然后将报告暴露为webservices

or any other better, guaranteed approach, i know it's dependant on the way my project is dealing, but i've shortage in time, so it depends on the approach having better documentations or tutorials.

或任何其他更好的、有保证的方法,我知道这取决于我的项目处理方式,但我时间不够,所以这取决于具有更好文档或教程的方法。

采纳答案by Konrad Garus

You can write your own Jasper framework in a module or subproject. You can maintain report definitions separately from queries and feed them with data produced by your code.

您可以在模块或子项目中编写自己的 Jasper 框架。您可以将报表定义与查询分开维护,并将您的代码生成的数据提供给它们。

This way all data and handling stays in your project where it's easier to track or edit (e.g. when you only need to change an aspect of the query, add a filter or rewrite it for better performance). Also, this way you can use report data for something else (e.g. add CSV or XML output).

通过这种方式,所有数据和处理都保留在您的项目中,以便于跟踪或编辑(例如,当您只需要更改查询的某个方面、添加过滤器或重写它以获得更好的性能时)。此外,通过这种方式,您可以将报告数据用于其他用途(例如,添加 CSV 或 XML 输出)。

回答by Jose Diaz

See http://en.wikipedia.org/wiki/JasperReportsfor the "What is" part of your question.

请参阅http://en.wikipedia.org/wiki/JasperReports了解问题的“什么是”部分。

I faced the same problems when considering to use Jasper-reports in my application, I ended up given it up completely.

我在考虑在我的应用程序中使用 Jasper-reports 时遇到了同样的问题,我最终完全放弃了它。

Anyway, take a look at this post for more information about different report frameworks for Java. Generating Reports - What works for you?

无论如何,请查看这篇文章,了解有关 Java 不同报告框架的更多信息。生成报告 - 什么对您有用?

I wholeheartedly recommend that you take a look at BIRT http://www.eclipse.org/birt/phoenix/

真心推荐大家看看BIRT http://www.eclipse.org/birt/phoenix/

I've used it with both Spring and Hibernate, and have no complain so far.

我已经将它与 Spring 和 Hibernate 一起使用,到目前为止没有任何抱怨。

回答by Rich

I can't comment on the other two approaches, but we are using Jasperserver and that seems to be more appropriate if you want to actually use a portal with which people will access their reports. With this, you create reports in ireport and publish them to the portal. People log in to the portal to access their reports. I don't think you'd use Jasperserver if you were simply embedding it in your application.

我无法评论其他两种方法,但我们正在使用 Jasperserver,如果您想实际使用人们可以访问其报告的门户,这似乎更合适。有了这个,您可以在 ireport 中创建报告并将它们发布到门户。人们登录门户以访问他们的报告。如果您只是将 Jasperserver 嵌入到您的应用程序中,我认为您不会使用它。

回答by Neil

I've started using JasperServer-pro recently and tbh I quite like it. As far as I know there seem to be plenty of options in the way of integrating it with existing apps :-

我最近开始使用 JasperServer-pro,我非常喜欢它。据我所知,将它与现有应用程序集成的方式似乎有很多选择:-

1 -Deploy as standalone server, and use the WebService API to call into to generate and return your reports (these have to be predefined, either through iReport or JasperServer's own AdHoc Report Editor.

1 - 部署为独立服务器,并使用 WebService API 调用以生成和返回您的报告(这些必须通过 iReport 或 JasperServer 自己的 AdHoc 报告编辑器进行预定义。

2- Deploy as standalone server, and do URL calls through a kicked-off browser to pull up reports (again predefined)

2- 部署为独立服务器,并通过启动浏览器进行 URL 调用以提取报告(再次预定义)

3 - (Pro-only) - Download the WAR BIN installer and rebrand it.

3 -(仅限专业版) - 下载 WAR BIN 安装程序并重新命名。

4 - Download the source code for JasperServer and build it from ground up

4 - 下载 JasperServer 的源代码并从头开始构建

5 - Download the source code / JasperReports jars and borrow the parts you want to use in your source code.

5 - 下载源代码 / JasperReports jars 并借用您想要在源代码中使用的部分。

回答by Gerbrand

For JasperReports can you buy documentation. You'll get a book and sample code that can help a lot. I just looked at the website (it's been some time ago I worked with JasperRepors, currently no reporting to do), they have a professional design application as well now: http://www.jaspersoft.com/jasperreports-professional.

对于 JasperReports,您可以购买文档。你会得到一本书和示例代码,它们会很有帮助。我刚刚看了网站(前段时间我与 JasperRepors 合作过,目前没有报告要做),他们现在也有一个专业的设计应用程序:http: //www.jaspersoft.com/jasperreports-professional