yoh/symfony-jasper-report-bundle

Symfony 3 Bundle,集成了Jasper Server REST v2客户端(Jaspersoft/rest-client)

安装数3,157

依赖者: 0

建议者: 0

安全: 0

星标: 4

关注者: 4

分支: 4

开放问题: 0

类型:symfony-bundle

v1.2 2017-05-19 08:57 UTC

This package is not auto-updated.

Last update: 2024-09-15 03:49:48 UTC


README

JasperReportBundle需要jaspersoft/rest-client,并在Symfony服务容器中提供了一个JasperReport-Client服务。

安装

1 将捆绑包添加到composer.json

    composer require yoh/symfony-jasper-report-bundle

2 在app/AppKernel.php中注册捆绑包

    $bundle = [
            ...
    		new Yoh\JasperReportBundle\YohJasperReportBundle(),
            ...
    ];

3 在app/config/config.yml中添加参数

    yoh_jasper_report:
        jrs_host:      "%jrs_host%"
        jrs_port:      "%jrs_port%"
        jrs_base:      "%jrs_base%"
        jrs_username:  "%jrs_username%"
        jrs_password:  "%jrs_password%"
        jrs_org_id:    "%jrs_org_id%"

4 在app/config/parameters.yml.dist中添加一个虚拟配置

    jrs_host:      127.0.0.1
    jrs_port:      8080
    jrs_base:      jasperserver
    jrs_username:  jasperadmin
    jrs_password:  jasperadmin
    jrs_org_id:    null

5 在app/config/parameters.yml中添加自己的配置

使用方法

现在您可以通过Symfony服务yoh.jasper.report访问Client对象。

    $client = $this->get('yoh.jasper.report')->getJasperClient();

使用报告服务

    $reportService = $client()->reportService();

因此,一个返回PDF报告的控制器看起来可能像这样

    public function reportAction(Request $request)
    {
    	$format = "pdf";
        $reportUnit = "/reports/sampleReport";
        $params = array(
            "Custom Label 1" => "Custom Value 1",
            "Custom Label 2" => "Custom Value 2"
        );

        return $this->get('yoh.jasper.report')->generate($reportUnit, $format, $params);
    }