public function actionPrintXsl() { $pro_rpt = new BirtReport(); $pro_rpt->reportPath = '@app/reports'; /* xsl output */ Yii::$app->response->format = 'raw'; Yii::$app->response->setDownloadHeaders('product_list.xls', 'Content-type: application/vnd.ms-excel'); return $pro_rpt->renderReport('master_product.rptdesign', [], BirtReport::OUTPUT_TYPE_XLS); }
public function run() { /* @var $request \yii\web\Request */ /* @var $response \yii\web\Response */ $request = Yii::$app->request; $response = Yii::$app->response; $reportName = $request->getQueryParam('name', $this->name); $outputType = $request->getQueryParam('outputType', $this->outputType); $params = $request->getQueryParam('params', []); $return = $this->report->renderReport($reportName, ['params' => $params], $outputType); if ($outputType != BirtReport::OUTPUT_TYPE_HTML) { $response->format = Response::FORMAT_RAW; $fileName = explode('.', $reportName, 1)[0] . '.' . $outputType; $mimeType = \yii\helpers\FileHelper::getMimeTypeByExtension($fileName); $response->setDownloadHeaders($fileName, $mimeType); } return $return; }