此输出存在问题。当用户单击按钮时,它应该吐出一个 excel 表。但是,对于某些用户,它会输出一个 HTML 页面。我感觉这与其他使用 IE7 而不是 IE10 的用户有关。但是,此功能应该适用于两者。
请帮忙。
如果您能发现错误,请告诉我:
$time = time();
$illegals = array('!', '*', "'", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]", "\"");
if(isset($_GET['ns_title'])) {$filename = str_replace($illegals,"",urldecode($_GET['ns_title'])).".xls"; } else { $filename = "myreport$time.xls"; }
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Expires: 0");
print "$headers\n$data";