承接 softworks/jasperphp 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

softworks/jasperphp

Composer 安装命令:

composer require softworks/jasperphp

包简介

Fork do JasperPHP com ajustes personalizados

README 文档

README

alt text

JasperPHP

Library to generate reports created with the JasperSoft Studio application
Pure PHP library, without a java server or Jasper Server

Please, consider donating funds to support us Donate

See more blog, documentation, and more on https://jasperphp.net

Export formats

PDF
XLS

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 Style OK
Frame OK dynamic table OK
* Subreports are supported recursively and unlimited

Other features

  • sum, average,minimum, max of variables
  • read and calculate subreport variables
  • array of objects as input data
  • textfield with html render with data replacement
  • active record
  • Conditional styles ready too
  • support for Laravel DB Facade adding tag `property name="net.sf.jasperreports.data.adapter" value="laravel.sqlsrv"` on jrxml files or edit Default data adapter on report properties on JasperSoft Studio

  • Generic sample

    <?php
    
    use JasperPHP\Report;
    use JasperPHP\ado\TTransaction;
    use JasperPHP\ado\TLogger;
    use JasperPHP\ado\TLoggerHTML;
    
    //use \NumberFormatter;
    //use PHPexcel as PHPexcel; // experimental
    /**
     * classe TJasper
     *
     * @author   Rogerio Muniz de Castro <rogerio@quilhasoft.com.br>
     * @version  2018.10.15
     * @access   restrict
     * 
     * 2015.03.11 -- create
     * 2018.10.15 -- revision and internationalize, add TLogger classes
     * */
    class TJasper {
    
        private $report;
        private $type;
        private $param;
    
        /**
         * method __construct()
         * 
         * @param $jrxml = a jrxml file name
         * @param $param = a array with params to use into jrxml report
         */
        public function __construct($jrxml, array $param) {
            $GLOBALS['reports'] = array();
            $xmlFile = $jrxml;
            $this->type = (array_key_exists('type', $param)) ? $param['type'] : 'pdf';
            //error_reporting(0);
            $this->param = $param;
            $this->report = new JasperPHP\Report($xmlFile, $param); // $GLOBALS['reports'][$xmlFile];
            switch ($this->type) {
                case 'pdf':
                    JasperPHP\Instructions::prepare($this->report);
                    break;
                case 'xls':
                    JasperPHP\Instructions::setProcessor('\JasperPHP\XlsProcessor');
                    JasperPHP\Instructions::prepare($this->report);
                    break;
                case 'xlsx':
                    //Process use 'PHPOffice/PhpSpreadsheet' 
                    JasperPHP\Instructions::setProcessor('\JasperPHP\XlsxProcessor');
                    JasperPHP\Instructions::prepare($this->report);
                    break;
            }
        }
    
        public function outpage($type = 'pdf') {
            $this->report->generate();
            $this->report->out();
            switch ($this->type) {
                case 'pdf':
                    $pdf = JasperPHP\Instructions::get();
                    $pdf->Output('report.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(JasperPHP\Instructions::$objOutPut, 'Excel5');
                    $objWriter->save('php://output');
                    break;
                case 'xlsx':
                    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 = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx(JasperPHP\Instructions::$objOutPut);
                    $objWriter->save('php://output');
                    break;
            }
        }
    
        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 , (probaly in composer instalations)
    require('../../phpoffice/phpexcel/Classes/PHPExcel.php'); // point to tcpdf class previosly instaled , (probaly in composer instalations)
    //require('../TCPDF/tcpdf.php'); // point to tcpdf class previosly instaled , (probaly in stand alone instalations)
    // on production using composer instalation is not necessaty
    
    //Assuming the 'xlsx' format use the 'phpoffice/phpspreadsheet' lib installation via 'composer require phpoffice/phpspreadsheet'
    
    $report_name = isset($_GET['report']) ? $_GET['report'] : 'testReport.jrxml';  // sql into testReport.txt report do not select any table.
    TTransaction::open('dev');
    TTransaction::setLogger(new TLoggerHTML('log.html'));
    $jasper = new TJasper($report_name, $_GET);
    $jasper->outpage();
    ?>

    Requirements

    • PHP 5.2+
    • "tecnickcom/tcpdf":"6.2.*"
    • "PHPOffice/PHPExcel" only of XLS export
    • "PHPOffice/PhpSpreadsheet" only of XLSX export

    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

    License

    • MIT License

    softworks/jasperphp 适用场景与选型建议

    softworks/jasperphp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

    它主要适用于以下技术方向: 「pdf」 「report」 「jaspersoft」 「jrxml」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

    我们在过去多个企业项目中使用过 softworks/jasperphp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

    围绕 softworks/jasperphp 我们能提供哪些服务?
    定制开发 / 二次开发

    基于 softworks/jasperphp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

    BUG 修复 & 性能优化

    线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

    项目外包 & 长期维护

    承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

    yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

    统计信息

    • 总下载量: 6
    • 月度下载量: 0
    • 日度下载量: 0
    • 收藏数: 0
    • 点击次数: 18
    • 依赖项目数: 0
    • 推荐数: 0

    GitHub 信息

    • Stars: 0
    • Watchers: 0
    • Forks: 32
    • 开发语言: PHP

    其他信息

    • 授权协议: MIT
    • 更新时间: 2025-07-01