Skip to content

PHP Jasper Reports XML

PhpReportes




Orden de los archivos y libreria 



<?php
    include_once 'phpjasperxml/PHPJasperXML.inc.php';//in this case, phpjasperxml is your submodule from github
    include_once '../config/dbconfig.php';

    $report=$_GET['rpt_name'];

    $PHPJasperXML = new PHPJasperXML("en","TCPDF"); //if export excel, can use PHPJasperXML("en","XLS OR XLSX");

    //$PHPJasperXML->debugsql=true;

    $PHPJasperXML->arrayParameter = array('para1'=>'1','para2'=>'2');

    $PHPJasperXML->load_xml_file($report.'.jrxml'); //if xml content is string, then $PHPJasperXML->load_xml_string($templatestr);

    //$PHPJasperXML->sql = $sql;  //if you wish to overwrite sql inside jrxml
    $dbdriver="mysql";//natively is 'mysql', 'psql', or 'sqlsrv'. the rest will use PDO driver. for oracle, use 'oci'
    $PHPJasperXML->transferDBtoArray($GLOBALS['dbhost'] ,$GLOBALS['userdb'] ,$GLOBALS['passdb'] ,'south2018',$dbdriver);

    //$PHPJasperXML->outpage('I=render in browser/D=Download/F=save as server side filename according 2nd parameter','filename.pdf or filename.xls or filename.xls depends on constructor')
    $PHPJasperXML->outpage('I');