public function oneword($id)
{
$tmp = new \PhpOffice\PhpWord\TemplateProcessor('D:\phpstudy_pro\WWW\one.docx');
$tmp->setValue('name', '大王');
$tmp->saveAs('导出.docx');
ob_clean();
ob_start();
$fp = fopen('./导出.docx', "r");
$file_size = filesize('./导出.docx');
Header("Content-type:application/octet-stream");
Header("Accept-Ranges:bytes");
Header("Accept-Length:" . $file_size);
Header("Content-Disposition:attchment; filename=" . '文件名.docx');
$buffer = 1024;
$file_count = 0;
while (!feof($fp) && $file_count < $file_size) {
$file_con = fread($fp, $buffer);
$file_count += $buffer;
echo $file_con;
}
fclose($fp);
ob_end_flush();
}
php word导出
最新推荐文章于 2023-09-11 08:49:25 发布