在PHP网站上使用Jasper报告 [英] using Jasper reports in a PHP website

查看:81
本文介绍了在PHP网站上使用Jasper报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Java报告的报告引擎来生成报告(HTML / PDF等)并在我的网站上显示它们。

I would like to use Java reports 'report engine' to generate reports (HTML/PDF etc) and display them on my website.

但是,我的网站使用的是PHP网络框架。任何人都可以建议我如何在PHP Web框架中使用Jasper Reports吗?

However, my website is using a PHP web framework. Can anyone suggest how I may be be able to use Jasper Reports within a PHP web framework?

推荐答案

如果你在Github上签出PHP REST客户端,或者通过Composer将它添加到您的PHP项目中,您将能够通过网络服务运行报告。

If you checkout the PHP REST Client on Github, or add it to your PHP project via Composer you will be able to run a report through web services.

您的代码应如下所示:

<?php
    $c = new \Jaspersoft\Client\Client(
    "http://localhost:8080/jasperserver-pro",
    "jasperadmin",
    "jasperadmin",
    "organization_1"
  );

    $report = $c->reportService()->runReport('/reports/samples/AllAccounts', 'html');
    echo $report;       
?>

这将检索HTML格式的报告并将其存储在 $ report 。当然,您可以将html更改为pdf或xls或您希望导出的任何格式。

That would retrieve a report in HTML format and store it in $report. Of course you can change html to pdf or xls or whatever format you wish to export to.

如果您希望显示PDF或提供下载,您必须将二进制数据提供给可以处理它的某个包,或者提供适当的标题,允许它通过Web浏览器下载。

If you wish to display PDFs or offer them for download, you will have to supply the binary data to some package that can handle it, or provide proper headers allowing it to be downloaded by a web browser.

我恰好是开发此包的人,如有任何问题,请随时给我打电话。

I happen to be the one developing this package, so feel free to shoot me a line with any questions.

这篇关于在PHP网站上使用Jasper报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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