Class 'Mpdf\Mpdf' 在 Phpspreadsheet 中找不到错误
Class 'Mpdf\Mpdf' not found error in Phpspreadsheet
我正在尝试借助 PHPSpreadsheet 将 excel 文件直接转换为 PDF。但出现错误“Class 'Mpdf\Mpdf' not found”,这是我的代码:
<?php
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf;
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load("excel.xlsx");
// when I use this MPDF class, I'm getting an error Class \Mpdf\Mpdf not found
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf($spreadsheet);
$writer->save("excel.pdf");
请帮助上面的代码。
谢谢
来自 phpspreadsheet 的 documentation:
You must now install a PDF rendering library yourself; but PhpSpreadsheet will work with a number of different libraries.
错误是因为没有安装您要使用的渲染库(在本例中为 mPDF)。只需将 mpdf/mpdf
添加到您的作曲家依赖项中即可。
我正在尝试借助 PHPSpreadsheet 将 excel 文件直接转换为 PDF。但出现错误“Class 'Mpdf\Mpdf' not found”,这是我的代码:
<?php
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf;
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load("excel.xlsx");
// when I use this MPDF class, I'm getting an error Class \Mpdf\Mpdf not found
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf($spreadsheet);
$writer->save("excel.pdf");
请帮助上面的代码。
谢谢
来自 phpspreadsheet 的 documentation:
You must now install a PDF rendering library yourself; but PhpSpreadsheet will work with a number of different libraries.
错误是因为没有安装您要使用的渲染库(在本例中为 mPDF)。只需将 mpdf/mpdf
添加到您的作曲家依赖项中即可。