Skip to content

PHP Generate Reports

Peter Gill edited this page Jun 24, 2013 · 15 revisions

Currently the RdlCmd php wrapper code is not bundled in a release. You must download a copy from master. To view online go to https://github.com/majorsilence/My-FyiReporting/tree/master/LanguageWrappers/php. Examples of using php is in the Examples folder in the above link.

Example of calling a basic report and generating the file hello2.pdf.

require_once("../report.php");

$rpt = new MyFyiReporting\Report("C:\\path\\to\\SimpleTest1.rdl");
$rpt->export("pdf", "C:\\output\path\hello2.pdf");

Example generating a report that has a parameter. Multiple parameters can be added using the set_parameter function. This example generates the file hello.pdf.

require_once("../report.php");

$rpt = new MyFyiReporting\Report('C:\\path\\to\\SimpleTestConnectionString.rdl');
$rpt->set_parameter("ConnectionString", 'Data Source=C:\\path\\to\\SqliteDatabaseFile.db;Version=3;Pooling=True;Max Pool Size=100;');
$rpt->export("pdf", "C:\\path\\to\\hello3.pdf");

This example generates a report and loads it into memory using the export_to_memory function. It then sends it to the browser to view or download.

require_once("../report.php");

$rpt = new MyFyiReporting\Report("C:\\path\\to\\SimpleTest1.rdl");
$data = $rpt->export_to_memory("pdf");

header("Content-type: application/octet-stream"); 
header("Content-disposition: attachment; filename=YourFileName2.pdf");
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
ob_clean();
flush();

echo $data;