Heim  >  Artikel  >  Backend-Entwicklung  >  php导出word文件,如何设置纸张格式?

php导出word文件,如何设置纸张格式?

WBOY
WBOYOriginal
2016-10-22 00:14:181473Durchsuche

<code>header('Content-type: application/octet-stream');
header("Content-Disposition: attachment; filename=\"路浩内部电话表.doc\"");</code>

?>

<code>


    <meta charset="UTF-8">
    <title>电话表</title>
    <style>
        th, .bm
        {
            font-family: SimHei;
            padding: 5px;
        }
        td
        {
            font-family: FangSong_GB2312;
            font-size: 14px;
            padding: 5px;
        }
        .num
        {
            font-family: 'Times New Roman';
            font-size: 14px;
            padding: 5px;
        }
    </style>


    <table border="1" cellpadding="0" cellspacing="0" align="center">
        <caption align="center" style="font-size:24px;padding:15px;font-family: SimHei;">内部电话表</caption>
        <tr>
            <th style="width:150px">部门</th>
            <th style="width:150px">职务</th>
            <th style="width:100px">姓名</th>
            <th style="width:150px">分机</th>
            <th style="width:150px">直拨号</th>
            <th style="width:150px">邮箱</th>
        </tr>
        <tr>
            <th style="width:150px">流程部</th>
            <th style="width:150px">代理人</th>
            <th style="width:100px">张三</th>
            <th style="width:150px">1827</th>
            <th style="width:150px">0302</th>
            <th style="width:150px">7129@qq.com</th>
        </tr>
    </table>




</code>

运行导出文件后效果如下图所示:
php导出word文件,如何设置纸张格式?
现在想要如下的效果,也就是设置成纸张的格式。应该什么做呢?
php导出word文件,如何设置纸张格式?

回复内容:

<code>header('Content-type: application/octet-stream');
header("Content-Disposition: attachment; filename=\"路浩内部电话表.doc\"");</code>

?>

<code>


    <meta charset="UTF-8">
    <title>电话表</title>
    <style>
        th, .bm
        {
            font-family: SimHei;
            padding: 5px;
        }
        td
        {
            font-family: FangSong_GB2312;
            font-size: 14px;
            padding: 5px;
        }
        .num
        {
            font-family: 'Times New Roman';
            font-size: 14px;
            padding: 5px;
        }
    </style>


    <table border="1" cellpadding="0" cellspacing="0" align="center">
        <caption align="center" style="font-size:24px;padding:15px;font-family: SimHei;">内部电话表</caption>
        <tr>
            <th style="width:150px">部门</th>
            <th style="width:150px">职务</th>
            <th style="width:100px">姓名</th>
            <th style="width:150px">分机</th>
            <th style="width:150px">直拨号</th>
            <th style="width:150px">邮箱</th>
        </tr>
        <tr>
            <th style="width:150px">流程部</th>
            <th style="width:150px">代理人</th>
            <th style="width:100px">张三</th>
            <th style="width:150px">1827</th>
            <th style="width:150px">0302</th>
            <th style="width:150px">7129@qq.com</th>
        </tr>
    </table>




</code>

运行导出文件后效果如下图所示:
php导出word文件,如何设置纸张格式?
现在想要如下的效果,也就是设置成纸张的格式。应该什么做呢?
php导出word文件,如何设置纸张格式?

你这个是空doc模板 表格啥的都是写入的自己?
这个好像可以做好doc模板 然后表格的内容写变量名 然后写入数据即可 具体你可以查查

php导出word文件,如何设置纸张格式?

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn