php导出excel再IE下乱码问题
程序员文章站
2022-07-26 11:44:26
$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');
上一篇: 围棋“人机大战”明日上演 李世石称五盘全胜并非易事
下一篇: 马云:机器更强大 人类更明智