Menu

Tree [705134] master /
 History

HTTPS access


File Date Author Commit
 app.jrxml 2019-01-22 Rctnet Rctnet [44c9c9] resolve conflicts
 config 2016-09-28 Rogerio Muniz Rogerio Muniz [8bb3d3] Inclusão do restante das bibliotecas
 samples 2019-01-22 Rctnet Rctnet [44c9c9] resolve conflicts
 src 2020-01-15 Rogerio Muniz Rogerio Muniz [548fe2] Many updates
 .gitignore 2018-10-11 Rogerio Rogerio [ecdb71] Update .gitignore
 LICENSE 2018-05-28 Rogerio Muniz Rogerio Muniz [2c30d6] UPDATE
 README.md 2020-01-16 Rogerio Muniz Rogerio Muniz [705134] Update README.md
 TJasper.class.php 2020-01-15 Rogerio Muniz Rogerio Muniz [548fe2] Many updates
 autoloader.php 2018-05-28 Rogerio Muniz Rogerio Muniz [2c30d6] UPDATE
 composer.json 2018-10-29 Rctnet Rctnet [5c6d0a] fix license
 docker-compose.yml 2018-05-28 Rogerio Muniz Rogerio Muniz [2c30d6] UPDATE
 log.html 2020-01-08 Rogerio Muniz Rogerio Muniz [9c8403] fix load jrxml file

Read Me

alt text

JasperPHP

Project to generate reports created with the JasperSoft Studio application

Pure PHP library, without a java server or Jasper Server

Consider donating funds to support us
Donate

See more blog, forum and coming soon report template store in https://jasperphp.com

Supported tags/components

TAG/component Status TAG/component Status
Basic elements
Text Field OK Static Text OK
Image OK Break OK
Rectangle OK Line OK
SubReport* OK Barcode OK
Composite elements
Page Number OK Total Pages OK
Current Date OK Page X of Y OK
Bands
Title OK Page Header OK
Group OK Detail OK
Column Header OK Column Footer OK
Page Footer OK Sumary OK
Background OK
  • Subreports are supported recursively and unlimited

Other features

<lu>
</lu>

  • active record



  • Generic sample

    <?php
    use JasperPHP\Report;
    use JasperPHP\Report2XLS;
    use JasperPHP\ado\TTransaction;
    use JasperPHP\ado\TLoggerHTML;
    
    //use PHPexcel as PHPexcel;
    /**
    * classe TJasper
    *
    * @author   Rogerio Muniz de Castro <rogerio@quilhasoft.net>
    * @version  2015.03.11
    * @access   restrict
    * 
    * 2015.03.11 -- create
    **/
    class TJasper
    {
        private $report;
        private $type;
    
        /**
        * method __construct()
        * 
        * @param $jrxml = a source xmlr filename
        * @param $param = a array whith params
        */
        public function __construct($jrxml,array $param)
        {
            $xmlFile=  $jrxml;
            $this->type = (array_key_exists('type',$param))?$param['type']:'pdf';
            error_reporting(0);
            switch ($this->type)
            {
                case 'pdf': 
                    $this->report =new JasperPHP\Report($xmlFile,$param);
                    JasperPHP\Pdf::prepare($this->report);
                    break;
                case 'xls':
                    JasperPHP\Excel::prepare();
                    $this->report =new JasperPHP\Report2XLS($xmlFile,$param);
    
                    break;
            }
        }
    
        /**
        * method outpage()
        * 
        * @param $type = a type of output. ALERT: xls is experimental
        */
    
        public function outpage($type='pdf'){
            $this->report->generate();
            $this->report->out();
            switch ($this->type)
            {
                case 'pdf':
                    $pdf  = JasperPHP\Pdf::get();
                    $pdf->Output('Relatorio.pdf',"I");
                    break;
                case 'xls':
                    header('Content-Type: application/vnd.ms-excel');
                    header('Content-Disposition: attachment;filename="01simple.xls"');
                    header('Cache-Control: max-age=0');
                    // If you're serving to IE 9, then the following may be needed
                    header('Cache-Control: max-age=1');
                    // If you're serving to IE over SSL, then the following may be needed
                    header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
                    header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
                    header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
                    header ('Pragma: public'); // HTTP/1.0
                    $objWriter = PHPExcel_IOFactory::createWriter($this->report->wb, 'Excel5');
                    $objWriter->save('php://output');
                break;
            }
    
        }
        /**
        * method setVariable()
         * insert variable into report after output
        * 
        * @param $name = name of variable
        * @param $value = value of variable
        */
        public function setVariable($name,$value){
            $this->report->arrayVariable[$name]['initialValue'] = $value ;
        }
    }
    require('autoloader.php') ;
    require('../../tecnickcom/tcpdf/tcpdf.php'); // point to tcpdf class previosly instaled , 
                                                // on composer instalation is not necessaty 
    
    TTransaction::open('dev');
    $jasper = new TJasper('template.jrxml',$_GET);
    $jasper->outpage();
    ?>
    

    Requirements

    • PHP 5.2+
    • "tecnickcom/tcpdf":"6.2.*"

    How to use this sample

    Define database conections params into file config\dev.ini

    View file src\ado\TConection.php to define database type

    Sample URL:

    http://localhost/vendor/quilhasoft/JasperPHP/TJasper.class.php?param1=foo&param2=bar

    URL params passed into URL are the params defined into xmlr file.

    Using composer

    Add "quilhasoft/jasperphp":"dev-master" into your composer config file and update/install

    Live samples

    • A basic test: Here
    • A burn test, 201 pages, hosted in a default hostgator server: Here
    • Brasilian payment method "boleto" in "carne":Here
    • Brasilian payment method "boleto" in A4 :Here

      ** Brasilian boleto project disponible in QuilhaSoft/JasperPHP-OpenBoleto.

    License

    • MIT License
    Want the latest updates on software, tech news, and AI?
    Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.