:::


9-7-3 使用 PhpWord 生成文件

一、建立一個 word檔 的基本結構:

require_once 'vendor/autoload.php';
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$filename = '新文件.docx';
$filename  = iconv("UTF-8", "Big5", $filename);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
header('Content-Type: application/vnd.ms-word');
header("Content-Disposition: attachment;filename={$filename}.docx");
header('Cache-Control: max-age=0');
$objWriter->save('php://output');

更多用法請參考:

  1. TAD 教材網:https://www.tad0616.net/modules/tad_book3/page.php?tbsn=44&tbdsn=1498

:::

好站推薦

[ more... ]