/**
* 支持过长数字单元格
*/functiondataToExcel2($header,$data,$filename='abc'){require(EXTEND_PATH.'excel/PHPExcel.php');$objPHPExcel=newPHPExcel();// Rename worksheet$objPHPExcel->getActiveSheet()->setTitle('Phpmarker-'.date('Y-m-d'));// Set active sheet index to the first sheet, so Excel opens this as the first sheet$objPHPExcel->setActiveSheetIndex(0);//设置headerif(!is_array($header)){returnfalse;}$ini=65;//A的acsii码foreach($headeras$value){$colum= \PHPExcel_Cell::stringFromColumnIndex($ini-65);$objPHPExcel->getActiveSheet()->setCellValue($colum.'1',$value);$ini++;}if(!is_array($data)){returnfalse;}$i=2;foreach($dataas$val){$ini=65;foreach($valas$item){$colum= \PHPExcel_Cell::stringFromColumnIndex($ini-65);$objPHPExcel->getActiveSheet()->setCellValueExplicit($colum.$i,$item);$ini++;}++$i;}// 输出Excel表格到浏览器下载header('Content-Type: application/vnd.ms-excel');header('Content-Disposition: attachment;filename="'.$filename.'.xls"');header('Cache-Control: max-age=0');// If you're serving to IE 9, then the following may be neededheader('Cache-Control: max-age=1');// If you're serving to IE over SSL, then the following may be neededheader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// Date in the pastheader('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');// always modifiedheader('Cache-Control: cache, must-revalidate');// HTTP/1.1header('Pragma: public');// HTTP/1.0$objWriter=newPHPExcel_Writer_Excel5($objPHPExcel);$objWriter->save('php://output');}