PHPExcel php execl下载或保存到本地_PHP教程

原创
2016-07-13 17:51:41 1439浏览

public static function saveExcel($objPHPExcel, $excelName, $output) {
$objWriter = PHPExcel_IOFactory::createWriter ( $objPHPExcel, 'Excel5' );
if (! strpos ( $_SERVER ['HTTP_USER_AGENT'], 'Firefox' ))
$excelName = urlencode ( $excelName );
if ($output) {
ob_end_clean ();
header ( "Content-Type: application/force-download" );
header ( "Content-Type: application/octet-stream" );
header ( "Content-Type: application/download" );
header ( "Content-Disposition: attachment; filename=" . $excelName . ".xls" );
header ( "Content-Transfer-Encoding: binary" );
header ( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header ( "Last-Modified: " . gmdate ( "D, d M Y H:i:s" ) . " GMT" );
header ( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header ( "Pragma: no-cache" );
$objWriter->save ( 'php://output' );
} else {
$objWriter->save ( "Excel/" . $excelName . ".xls" );
echo '';
}
}


摘自 lpdx111的专栏

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478172.htmlTechArticlepublic static function saveExcel($objPHPExcel, $excelName, $output) { $objWriter = PHPExcel_IOFactory::createWriter ( $objPHPExcel, Excel5 ); if (! strpos ( $_SERVER [HTTP_USER_AGE...

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
上一条:PHP仿博客园,个人博客(1)_PHP教程 下一条:PHP仿博客园,个人博客(2)_PHP教程

相关文章

查看更多