这是我在控制器中的操作,但它给了我这个错误:
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
//设置样本目录的别名
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');
答案 0 :(得分:0)
设置别名时缺少@
,请更改以下内容
Yii::setAlias('example', '@vendor/chrmorandi/yii2-jasper/examples');
到
Yii::setAlias('@example', '@vendor/chrmorandi/yii2-jasper/examples');