我正在使用这个代码
include 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
if(isset($_POST["export"]))
{
$file = new Spreadsheet();
$active_sheet = $file->getActiveSheet();
$active_sheet->setCellValue('A1', 'Zone');
$active_sheet->setCellValue('B1', 'Customer');
$active_sheet->setCellValue('C1', 'Competitor');
$count = 2;
foreach($all as $row)
{
$active_sheet->setCellValue('A' . $count, $row["depot"]);
$active_sheet->setCellValue('B' . $count, $row["customer"]);
$active_sheet->setCellValue('C' . $count, $row["name"]);
$count = $count + 1;
}
ob_clean();
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($file, $_POST["file_type"]);
$file_name = 'Competitor Insights.' . strtolower($_POST["file_type"]);
$writer->save($file_name);
header('Content-Type: application/x-www-form-urlencoded');
header('Content-Transfer-Encoding: Binary');
header("Content-disposition: attachment; filename=\"".$file_name."\"");
readfile($file_name);
unlink($file_name);
exit;
}
在服务器上出现此错误:
PHP 致命错误:未捕获错误:调用未定义函数 PhpOffice\PhpSpreadsheet\Shared\mb_strlen() 中 /home/spectra3/public_html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/StringHelper.php:451