我为一个网站开发了报告系统。我开发了脚本,以便我的客户可以在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";