错误导出为PDF。我想作曲家更新和添加的东西到app.php ANF composer.json
public function exportPDF($request, $orgid)
{
/*$pdf = App::make('snappy.pdf.wrapper');
$pdf->loadHTML('<h1>Test</h1>');
return $pdf->inline();*/
$data = User::get()->toArray();
return Excel::create('itsolutionstuff_example', function($excel) use ($data) {
$excel->sheet('mySheet', function($sheet) use ($data)
{
$sheet->fromArray($data);
});
})->download("pdf");
}
至极的PDF渲染器都设置了?根据该文件,你有3种选择,TCPDF,MPDF和DOMPDF。你必须安装它们中的至少一个。
composer require mpdf/mpdf
然后直接PHPExcel使用它
$renderer = PHPExcel_Settings::PDF_RENDERER_MPDF;
$rendererPath = dirname(__FILE__).'/../../../libraries/PDF/mPDF6.1'
if (!PHPExcel_Settings::setPdfRenderer(
$renderer,
$rendererPath
)) {
die('Wrong setup of PDF libraries');
}
请评论在DomPDF.php这一行
if (file_exists($pdfRendererClassFile)) {
require_once $pdfRendererClassFile;
} else {
throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
}
至
/** Require DomPDF library */
//$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/dompdf_config.inc.php';
//if (file_exists($pdfRendererClassFile)) {
// require_once $pdfRendererClassFile;
//} else {
// throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
//}
希望它的作品。