为什么我在将 html 页面导出到 word 时出现错误?

我在尝试添加表格的新行时遇到错误,一切正常,我可以将我的 html 页面导出到 MS Word。


我收到这样的错误


Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\test\exportword2.php:216) in C:\xampp\htdocs\test\exportword2.php on line 217


Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\test\exportword2.php:216) in C:\xampp\htdocs\test\exportword2.php on line 218


Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\test\exportword2.php:216) in C:\xampp\htdocs\test\exportword2.php on line 219


Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\test\exportword2.php:216) in C:\xampp\htdocs\test\exportword2.php on line 220

这是我的代码


        <tr>

            <td>13. </td>

            <td>Upah Pekerja</td>

            <td>:</td>

            <td>Minimum</td>

            <td colspan="4">Rp. 100000</td>

        </tr>

        <tr>

            <td></td>

            <td></td>

            <td>:</td>

            <td>Maximum</td>

            <td colspan="4">Rp. 100000</td>

        </tr>

        <tr>

            <td></td>

            <td>Upah Pekerja Harian</td>

            <td>:</td>

            <td>Minimum</td>

            <td colspan="4">Rp. 100000</td>

        </tr>

        <tr>

            <td></td>

            <td></td>

            <td>:</td>

            <td>Maximum</td>

            <td colspan="4">Rp. 100000</td>

        </tr>

        <tr>

            <td>14.</td>

            <td>Sistem Hubungan Kerja</td>

            <td colspan="6">:</td>

        </tr>

        <tr>

            <td></td>

            <td>a. Untuk Waktu Tertentu</td>

            <td colspan="6">: 3 Orang</td>

        </tr>

        <tr>

            <td></td>

            <td>b. Untuk Waktu Tidak Tertentu</td>

            <td colspan="6">: 3 Orang</td>

        </tr>

    </table>


我已经完成导出,直到我添加新的表行,我收到上面的错误

哔哔one
浏览 51回答 1
1回答

aluckdog

请参阅文档:header() 必须在发送任何实际输出之前调用,无论是通过正常的 HTML 标签、文件中的空行还是从 PHP 发送。使用 include、require、函数或其他文件访问函数读取代码,并在调用 header() 之前输出空格或空行是一个非常常见的错误。使用单个 PHP/HTML 文件时也存在同样的问题。<?php// header must be before any sent output header("Content-Type: application/vnd.msword");header("Expires: 0");header("Cache-Control: must-revalidate, post-check=0, pre-check=0");header("content-disposition: attachment;filename=hasilekspor.doc"); ?><html>...</html>
打开App,查看更多内容
随时随地看视频慕课网APP