PHPExcel php execl 下载 或 保存到本地
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>";
}
}
$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>";
}
}
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: C语言的fopen函数(文件操作/读写)
- 下一篇: Linux 文件编程—fopen函数