我为一个网站开发了报告系统。我开发了脚本,以便我的客户可以在 XLS 文件中导出所有详细信息的销售数据,一切正常,但现在我注意到每个生成的 xls 文件顶部都有空白行,我没有对代码进行任何更改,几天前它没有发生。如何从顶部删除该空行
我正在使用以下代码生成 xls 文件:
$str = "No\tOrderId\tFirst Name\tLast Name\tOrder Date\tTime\tAddress\tCity\tState\tZip\tCountry\tPhone\tEmail\tProductId\tProductName\tProductQty\t";
$output = array();
$output[] = $str;
while($row = $res->fetch())
{
$datetime = new DateTime($row['DateTime']);
$date = $datetime->format('Y-m-d');
$time = $datetime->format('H:i:s');
$Country = getCountryName($row['Country']);
$stroutput= $cnt."\t".$row['OrderId']."\t".stripslashes($row['FirstName'])."\t".stripslashes($row['LastName'])."\t".$date."\t".$time."\t".$row['Address1']."\t".$row['City']."\t".$row['State']."\t".$row['Zip']."\t".$Country."\t".$row['Phone']."\t".$row['Email']."\t".$row['ProductId']."\t".$row['ProductName']."\t".$row['ProductQty']."\t";
$output[]=$stroutput;
$cnt++;
}
$filename="CustomReport_".$date33."_".$date55."_".date("mdy-His");
$data = implode("\n", $output);
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$filename.".xls;");
header("Content-Type: application/ms-excel");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";