<?php $ua = strtolower($_SERVER['HTTP_USER_AGENT']); if(preg_match('/msie/', $ua) || preg_match('/edge/', $ua)) { $filename = str_replace('+', '%20', urlencode($filename)); } ob_end_clean();//清除緩衝區,避免亂碼 // Redirect output to a client’s web browser (Excel5) header("Cache-Control:must-revalidate, post-check=0, pre-check=0"); header("Content-Type:application/force-download"); header("Content-Type:application/vnd.ms-execl"); header("Content-Type:application/download"); header('Content-Disposition:attachment;filename="'.$filename.date('Y-m-d',time()).'.xls"'); ?>