程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> PHPExcel php execl下載或保存到本地

PHPExcel php execl下載或保存到本地

編輯:關於PHP編程

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 '<script language="javascript" type="text/javascript">window.top.window.stopUpload(1);</script>';
  }
 }

 


摘自 lpdx111的專欄

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved