当我使用 PHP 导出 Excel 时,任何人都可以帮助我如何删除此警告。
您尝试打开的文件“example.xls 的格式与文件扩展名指定的格式不同。
这是我的代码,请说明哪里做错了
<?php
// Start a session
session_start();
// Define variables from $_SESSION and $_GET
$firstname = $_SESSION['firstname'];
$lastname = $_SESSION['lastname'];
$username = $_SESSION['username'];
$start = $_GET['start'];
$end = $_GET['end'];
$ProviderID = $_GET['ProviderID'];
$summarytype = $_GET['summarytype'];
$subspeciality = $_GET['subspeciality'];
$export = $_GET['export'];
// Connect to mysql db
include ("access.php");
header("Content-type: application/vnd.ms-excel; name='excel'");
header("Content-Disposition: filename=export.xls");
// Fix for crappy IE bug in download.
header("Pragma: ");
header("Cache-Control: ");
error_reporting("E_ALL");
$sql = "SELECT *, master.EmtracSigChange AS 'SigChange' FROM master, nightrad WHERE master.EmtracSigChange='Yes' AND master.MaryGrade!='' AND master.InternalExamID=nightrad.InternalExamID AND master.TranscriptionDTTM <= '$end' AND master.TranscriptionDTTM >= '$start'";
$result = mysql_db_query('testDb',$sql);
if(!$result) {
echo "<p>No matches to your query</p>";
echo "<p>Click back on your browser to change your query parameters.</p>";
die(mysql_error());
}
?>
<html>
<head></head>
<body>
<table border="1" cellspacing="0" cellpadding="3">
<tr>
<th bgcolor="#0099FF" scope="col">Accession</th>
<th bgcolor="#0099FF" scope="col">Transcribed</th>
<th bgcolor="#0099FF" scope="col">Turnaround time</th>
<th bgcolor="#0099FF" scope="col">Attending</th>
<th bgcolor="#0099FF" scope="col">Res or fellow</th>
<th bgcolor="#0099FF" scope="col">Modality</th>
<th bgcolor="#0099FF" scope="col">Exam</th>
<th bgcolor="#0099FF" scope="col">Discrepancy</th>
<th bgcolor="#0099FF" scope="col">Folder</th>
<th bgcolor="#0099FF" scope="col">Comment</th>
</tr>
<?php
// Add all values in the table to $out.
while ($row = mysql_fetch_assoc($result)) {
$CompletedDTTM = $row['CompletedDTTM'];
$TranscriptionDTTM = $row['TranscriptionDTTM'];
$date = date("Y-m-d", strtotime($TranscriptionDTTM));
// Converting turnaround time from DTTM to time
$parsedtime = strtotime($CompletedDTTM . " GMT");
$convertedtime = gmdate("H:i:s", $parsedtime);
$parsedtime1 = strtotime($TranscriptionDTTM . " GMT");
$convertedtime1 = gmdate("H:i:s", $parsedtime1);
$parsedtat = $parsedtime1 - $parsedtime;
$turnaroundtime = gmdate("H:i", $parsedtat);
?>
<tr >
<td><?php echo $row['AccessionNumber']; ?></td>
<td><?php echo $date; ?></td>
<td><?php echo $turnaroundtime; ?></td>
<td><?php echo $row['AttendingLastName']; ?></td>
<td><?php echo $row['LastName']; ?></td>
<td><?php echo $row['Modality']; ?></td>
<td><?php echo $row['ExamDesc']; ?></td>
<td><?php echo $row['MaryGrade']; ?></td>
<td><?php echo $row['MaryFolder']; ?></td>
<td><?php echo $row['MaryComment'] ?></td>
</tr>
<?php
}
?>
</table>
</body>
</html>
它给了我数据,但问题是当我尝试打开它时也会显示警告消息。请帮助