如何使用yii2用户cossou / jasperphp生成报告

时间:2018-01-10 16:57:17

标签: php yii2 jasper-reports

它说Class 'cossou\JasperPHP\JasperPHP' not found。 我使用这个类作为命名空间

$jasper = new JasperPHP;

    //jasper ready to call
    $jasper->compile(__DIR__ . '/../../vendor/cossou/jasperphp/examples/hello_world.jrxml')->execute();

        // Process a Jasper file to PDF and RTF (you can use directly the .jrxml)
    $jasper->process(
        __DIR__ . '/../../vendor/cossou/jasperphp/examples/hello_world.jasper',
        false,
        array("pdf", "rtf"),
        array("php_version" => phpversion())
    )->execute();

    // List the parameters from a Jasper file.
    $array = $jasper->list_parameters(
        __DIR__ . '/../../vendor/cossou/jasperphp/examples/hello_world.jasper'
    )->execute();

    return $this->redner('view');

1 个答案:

答案 0 :(得分:0)

添加到您的文件顶部

use JasperPHP\JasperPHP as JasperPHP

然后将其称为

$jasper = new JasperPHP;