首頁 > php教程 > php手册 > 主體

PHPExcel php execl下载或保存到本地

WBOY
發布: 2016-06-13 10:50:07
原創
1432 人瀏覽過

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的专栏

來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!