开发者

PHP variable passed to JasperReports Server for reports

开发者 https://www.devze.com 2022-12-27 22:22 出处:网络
Is it possible to pass a variable from php to a report in JasperReports Server?For example, in my php application I keep the department_id stored in a session variable.I would like to pass t开发者_Pyt

Is it possible to pass a variable from php to a report in JasperReports Server? For example, in my php application I keep the department_id stored in a session variable. I would like to pass t开发者_Python百科he department_id over to my reports running on JasperReports Server and display the information appropriate for that department. in the iReport I have a query like: SELECT * FROM employees WHERE department_id = $P{dept_id_from_php}, but I have to build a dropdown select list to pass the dept_id parameter.

The end result is I would like the user logged into my PHP application to view the employee information that is related to the department the logged-in-user belongs to. I don't want to pass this over using the querystring because the user could just change the id in the querystring and have access to other departments information. Ideally I would like to only pass that parameter once, then reuse it in all the reports, like a global variable.

Is this possible?


There is a terrific (small) php SOAP interface here https://github.com/adlermedrado/PHP-JasperServer-Integration for this purpose. It should save some time!

//example
//construct report object
$report    =    array("_REPORT_PARAMETER"=>$php_variable);

//valid output PDF, JRPRINT, HTML, XLS, XML, CSV and RTF
$jasper->run('/path/_Standard_Report','PDF',$report,false);

It should be noted that I have not had great success with XLS export, but other formats seem to work very well.

0

精彩评论

暂无评论...
验证码 换一张
取 消