:::
上中區域內容
主內容區域
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');
更多用法請參考:
- TAD 教材網:https://www.tad0616.net/modules/tad_book3/page.php?tbsn=44&tbdsn=1498
9-7-2 使用 Composer 安裝 PhpWord


