我有一个html文件转换为MS Word。我的PHP代码如下:
include("connection.php");
extract($_REQUEST);
ob_start();
include("counties/$county_name/$file");
$html_content = ob_get_contents();
ob_end_clean();
header("Content-type: application/vnd.ms-word");
header("Content-Disposition:attachment;Filename=3_day_notice_fad_word/$html_content");
但它不起作用。
答案 0 :(得分:0)
有一个API。请仔细阅读。
https://github.com/PHPOffice/PHPWord
您可以在上面的链接页面中看到,他们转换了以下内容:
// Saving the document as OOXML file...
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('helloWorld.docx');