Skip to content

Do something beyond standard data source

Ks Tan edited this page Sep 6, 2019 · 17 revisions
  1. Using dynamic sql, which is not exists in jrxml file:
$sql="SELECT * FROM table1";
$PHPJasperXML->load_xml_file('file1.jrxml'); 
$PHPJasperXML->sql = $sql;  
  1. Using flexible data using array:
$data=[
    ["id"=>1,"name"=>"John","age"=>30],
    ["id"=>2,"name"=>"Mr Lee","age"=>23],
];
$PHPJasperXML->load_xml_file('file1.jrxml'); 
$PHPJasperXML->setData($data);
  1. Use php variable/function instead of jasper report rules In text field, usually you define something as $F{column1}, that is follow Jaspersoft standard. In fact, it is very restricted and lot of time insufficient for complex case. We can do something as when necessary:
$mycompanyname="Sim It Sdn Bhd";
function mytime(){
 return date('Y-m-d');
}
...load phpjasperxml...

then, in jrxml's text field. you can simply pass php function or variable such as $mycompanyname or mytime().

Clone this wiki locally