YiiJasper
Yii libraries to use Jasper Server Reports
This extension provides access to show Jasper Reports in Yii from Jasper Server.
Note: This IS NOT a .jrxml parser version, you must install Jasper Server
Installation: ¶
Copy YiiJasper folder to yii extensions folder.
You can import the extension where you use this or in the config main adding
'import'=>array(
//...
'ext.YiiJasper.*',
),
Then you need configure some parameters in JasperReport.php to communicate with your Jasper Server:
/* Jasper server URL (Default Value) */
protected $baseUrl = 'http://localhost:8080/jasperserver/';
/* Jasper server username (Default Value) */
protected $jusername = 'jasperadmin';
/* Jasper server password (Default Value) */
protected $jpassword = 'jasperadmin';
Requirements ¶
Yii Version 1.1.14
Installed and working Jasper Server (Tested in Community v5.2.0)
Usage ¶
Examples for basic usage
/* Html Report */
$pages = '1-4';
$re = new JasperReport('/reports/samples/AllAccounts');
$re->exec();
echo $re->toHTML($pages); //Page 1 to 4
/* Pdf Report */
$re = new JasperReport('/reports/samples/AllAccounts');
$re->exec();
echo $re->toPDF(); //All pages
/* Xls Report */
$re = new JasperReport('/reports/samples/AllAccounts');
$re->exec();
echo $re->toXLS(8); //Page 8
/* Widget Report, Html report with pagination */
$this->widget('JReportView', array(
'pathReport'=>'/reports/samples/AllAccounts',
));
Resources ¶
GitHub repository - https://github.com/cezario/yiijasper
Demo ¶
- Demo file is included in download file, but I recommend download from GitHub
Where is the Ext?
Hi, where is the download file?
Tomorrow :)
Hello Gustavo, tomorrow I'll upload it, was going to go up now but I was a little busy.
In this page I'll to put the link.
Exception 'Limite de tiempo excedido, por favor intente de nuevo'
Hi:
I'm just getting started with Jasper Reports and tried your extension but am getting the timeout error even with a very simple report. Any ideas?
Thanks,
Re: Exception 'Limite de tiempo excedido, por favor intente de nuevo'
Hi, this error can be appear when the yiijasper can't be connect with jasperserver, first check in your browser that you Jasper Server is running, you must see a window like this:
http://oi41.tinypic.com/2crskef.jpg
Then check if you can loggin with the params that you have in class JasperReport
protected $baseUrl = 'http://localhost:8080/jasperserver/'; protected $jusername = 'jasperadmin'; protected $jpassword = 'jasperadmin';
If everything it's ok, check if report path it's correct, you can copy this from the Jasper Server web interface
http://oi43.tinypic.com/2e0rzuq.jpg
Finally check the time of execution for your report, if takes a lot of time, you must wait to execution finish to show the report, you can check the status with the method "isReady" and the exportID
Let me know how it goes.
How to pass parameter?
How can I add report parameters? Could you please give an example?
Re: Exception 'Limite de tiempo excedido, por favor intente de nuevo'
After some experimentation I got it: the pathname was wrong because I though it was relative to the Yii app but instead is relative to the JR server "root".
Thanks!
José
Parameters example
Hi Jose, it is good to know is working.
Hi Girish, you need to send parameters in one associative array,
array('param1' => 'value1', 'param2' => 'value2', 'param3' => 'value3',...)
Suppose you have report with a query like that:
And you want to show, all students in the group B:
$re = new JasperReport('/reports/students', JasperReport::FORMAT_HTML, array( 'group' => 'B', )); $re->exec(); $html = $re->toHTML();; $this->render('groups', array( 'html' => $html, ));
JasperReport::FORMAT_HTML is the initial format, you can export later if is necesary.
Here you show a widget with students in group C:
$this->widget('JReportView', array( 'pathReport'=>'/reports/students', 'params' => array( 'group' => 'C', ) ));
Using $this when not in object context
Hello, when I try to access http://localhost/demo/index.php?r=site/index I got this err :
"Using $this when not in object context" is there anything wrong in my setting ? Please help, thank you
Using $this when not in object context
Hello C.S.Putera, I don't have any error with the url demo/index.php?r=site/index, I need more information to replicate the error or you can download and try again.
Note: Check your php version, the server must have PHP 5.1 or above, I tested this in PHP 5.4.9
Using $this when not in object context
Yes, my php version is above 5.1, I still cannot figure out why, but if I access the actionPdf, it runs well
Re:Conflicting JS
Hello, What is your Jasper Server version?
limite de tiempo exceded, por favor intente de nuevo
Hi,
I am cracking my head for this error! - limite de tiempo exceded, por favor intente de nuevo
Couldn't find the solution.
Pls someone help me!
Solution :::: limite de tiempo exceded, por favor intente de nuevo
Dear All,
please do use Jasper Server Reports version 5.5.x...
N.B:: do not use Jasper Server Reports version 5.6.x or more
Thank you
SelimReza.com
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.