Php 将html表格导出到ms word
我有一个html表格,格式如下:Php 将html表格导出到ms word,php,javascript,phpdocx,Php,Javascript,Phpdocx,我有一个html表格,格式如下: <table> <tr> <td></td> <td></td> </tr> </table> 我有一个下载按钮: <input type="text" name="download" value="Download"> 我需要在用户单击下载按钮时以ms word格式导出/下载此表。请帮助我的代码来实现这
<table>
<tr>
<td></td>
<td></td>
</tr>
</table>
我有一个下载按钮:
<input type="text" name="download" value="Download">
我需要在用户单击下载按钮时以ms word格式导出/下载此表。请帮助我的代码来实现这一点。
提前感谢这里有一个名为的库,可以从PHP使用。甚至还有。那里的代码如下所示:
require_once 'pathToPHPDocX/classes/CreateDocx.inc';
$docx = new CreateDocx();
$html='<p>some html</p>';
$docx->embedHTML($html);
$docx->createDocx('simpleHTML');
您可以尝试设置脚本头的简单解决方案
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=YOUR_DOC_NAME.doc");
echo '<table>....';
这将强制用户将所有回音下载到ms word文档中,请尝试以下操作:
它的工作。我也在用它
header("Content-Type: application/vnd.msword");
header("content-disposition: attachment;filename=sampleword.doc");
尝试一些自由职业者网站获得代码帮助,以实现这一点,我们不为对方编码,所以我们帮助对方编码或调试。