header("Content-Type: application/force-download", false); header("Content-Type: application/octet-stream", false); header("Content-Type: application/download", false); header("Content-Transfer-Encoding: binary"); header("Content-type : application/vnd.ms-excel", false); header("Cache-control: private"); // get the browser name $browser = $_SERVER['HTTP_USER_AGENT']; // deal with ie5/6 bug if (preg_match('/MSIE 5.5/', $browser) || preg_match('/MSIE 6.0/', $browser)) { header('Content-Disposition: filename="'.$filename.'"'); } else { header('Content-Disposition: attachment; filename="'.$filename.'"'); }