我在通过PHP下载Excel时遇到问题。
仅应下载所需的数据,但结果均为下载的html主题。
header("content-type: application/vnd-ms-exel");
header("Content-Disposition: attachment; filename=Praktisi PAZ Indonesia.xls");
header("Pragma: no-cache");
header("Expires: 0");
?>
<table class="table table-bordered" border="1px">
<thead>
<tr>
<th style="width:3%;background-color:silver;">No.</th>
<th style="background-color:silver;">Nama</th>
<th style="background-color:silver;">Email</th>
<th style="background-color:silver;">Telepon</th>
</tr>
</thead>
<tbody>
<?php
$no=1;
$H_P = $Mod_Tampil->tampil_all($db,"SELECT NAMA_PENGGUNA, EMAIL_PENGGUNA, TELEPON_PENGGUNA FROM PENGGUNA");
if (!empty($H_P[1])) {
foreach ($H_P[1] as $D_P) { ?>
<tr>
<td style="text-align:left;"><?= $no++."."; ?></td>
<td><?= $D_P[0]; ?></td>
<td><?= $D_P[1]; ?></td>
<td><?= $D_P[2]; ?></td>
</tr>
<?php }
} ?>
</tbody>
</table>