首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在yii2中使用chrmorandi\yii2 i2jasper

如何在yii2中使用chrmorandi\yii2 i2jasper
EN

Stack Overflow用户
提问于 2018-01-11 08:20:10
回答 1查看 199关注 0票数 0

这是我在控制器中的操作,但它给出了这个错误:

代码语言:javascript
复制
Your report has an error and couldn't be processed! 
Try to output the command: C:^^^\xampp^^^\htdocs^^^\pay^^^\vendor^^^\chrmorandi^^^\yii2-jasper^^^\src^^^\Jasper/../JasperStarter/bin/jasperstarter 
compile C:^^^\xampp^^^\htdocs^^^\pay/vendor/chrmorandi/yii2-jasper/examples/shipments_report.jrxml

//设置sample目录的别名

代码语言:javascript
复制
    Yii::setAlias('@example', '@vendor/chrmorandi/yii2-jasper/examples');

    /* @var $jasper Jasper */
    $jasper = Yii::$app->jasper;

    // Compile a JRXML to Jasper
    $jasper->compile(Yii::getAlias('@example') . '/shipments_report.jrxml')->execute();

    // Process a Jasper file to PDF and RTF (you can use directly the .jrxml)
    $jasper->process(
        Yii::getAlias('@example') . '/shipments_report.jasper', 
        ['php_version' => '7.1.11'],
        ['pdf', 'rtf'],
        false, 
        false 
    )->execute();

    // List the parameters from a Jasper file.
    $array = $jasper->listParameters(Yii::getAlias('@example') . '/shipments_report.jasper')->execute();

    // return pdf file
    Yii::$app->response->sendFile(Yii::getAlias('@example') . '/shipments_report.pdf');
EN

回答 1

Stack Overflow用户

发布于 2018-01-11 08:57:58

设置别名时缺少@,请更改以下内容

代码语言:javascript
复制
Yii::setAlias('example', '@vendor/chrmorandi/yii2-jasper/examples');

代码语言:javascript
复制
Yii::setAlias('@example', '@vendor/chrmorandi/yii2-jasper/examples');
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48198138

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档