要包含在网页中的 Java 报告库

发布于 2024-10-06 02:24:55 字数 387 浏览 0 评论 0原文

我正在开发 Grails 应用程序,需要显示一些报告并允许用户以最常见的格式(PDF、XML...)导出它们。

我不想将 SQL 查询嵌入到报告定义中,报告逻辑已集成到 Grails 服务中,并且我正在寻找的报告库应该适用于没有真实数据源的数据集(可能是地图列表)。

我使用 Jasper Reports 和 iReport 进行测试,它们与 Grails 配合使用,可实现导出功能(PDF、XML、HTML)。但我很难将它们包含到我的页面模板中。我希望在报告 html 中包含页眉、页脚、导航菜单和过滤器。

我想到的唯一解决方案是使用 iframe,但我不太喜欢这个。

Jasper Report 可以满足我的要求吗?您是否知道任何其他 Java 报告库允许我将报告包含在 HTML 正文中?

I'm working on a Grails application and I need to display some reports and allow the users to export them in the most common formats (PDF, XML...).

I don't want to embed the SQL query into the report definition, the report logic is integrated into Grails services and the reporting library I'm looking for should work on a dataset (maybe a list of maps) without a real datasource.

I used Jasper Reports and iReport for my tests and they work great together with Grails for the exporting functionality (PDF, XML, HTML). But I have difficult including them into my page template. I would like to have my header, footer, navigation menu and filter within the report html.

The only solution that came in my mind was to use iframe but I don't like this so much.

Can Jasper Report address my request? do you know any other Java reporting library that allows me to include the report in my HTML body?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦萦几度 2024-10-13 02:24:55

您可以使用 g:include 标签包含控制器的响应:

<g:include controller="myJasper" action="showReport" 
    params="[foo: 'bar', baz: 42]" />

使用 Grails Jasper 插件,您的控制器将包含如下代码:

import org.codehaus.groovy.grails.plugins.jasper.JasperExportFormat;
import org.codehaus.groovy.grails.plugins.jasper.JasperReportDef;

class MyJasperController {
    def jasperService

    def showReport = {
        def reportDef = new JasperReportDef(
            name: 'your_report.jasper', 
            parameters: params,
            fileFormat: JasperExportFormat.HTML_FORMAT)

        def report = jasperService.generateReport(reportDef)
            .toByteArray().toString("UTF-8")

        render report
    }
}

You can use the g:include tag to include a controller's response:

<g:include controller="myJasper" action="showReport" 
    params="[foo: 'bar', baz: 42]" />

Using the Grails Jasper plugin, your controller then would contain code like this:

import org.codehaus.groovy.grails.plugins.jasper.JasperExportFormat;
import org.codehaus.groovy.grails.plugins.jasper.JasperReportDef;

class MyJasperController {
    def jasperService

    def showReport = {
        def reportDef = new JasperReportDef(
            name: 'your_report.jasper', 
            parameters: params,
            fileFormat: JasperExportFormat.HTML_FORMAT)

        def report = jasperService.generateReport(reportDef)
            .toByteArray().toString("UTF-8")

        render report
    }
}
请你别敷衍 2024-10-13 02:24:55

有大量适用于 Java 的 Web 报告 API。看看这里:

http://java-source.net/open-source /图表和报告

There are plenty of web reporting apis for Java. Just take a look here:

http://java-source.net/open-source/charting-and-reporting

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文