php导出excel再IE下乱码问题
程序员文章站
2022-04-24 16:05:54
$userBrowser = $_SERVER['HTTP_USER_AGENT']; //判断是否是ie内核 $fileName = '会员列表-'.date('Y-m-d', time()).'.xls'; if( preg_match( '/MSIE/i', $userBrowser ) ) ... ......
$userBrowser = $_SERVER['HTTP_USER_AGENT']; //判断是否是ie内核 $fileName = '会员列表-'.date('Y-m-d', time()).'.xls'; if( preg_match( '/MSIE/i', $userBrowser ) ) { $fileName = urlencode($fileName); }else{ $fileName = iconv('UTF-8', 'GBK//IGNORE', $fileName); } header('pragma:public'); header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename='.$fileName.''); //日期为文件名后缀 header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); //excel5为xls格式,excel2007为xlsx格式 $objWriter->save('php://output');