首页 > 代码库 > phpexcel使用实例
phpexcel使用实例
if($_GPC[‘export‘] != ‘‘){ include(dirname(__FILE__).‘/./PHPExcel-1.8/Classes/PHPExcel.php‘); $template = ‘./sdpost2.xlsx‘; //var_dump($_GPC); $objReader = PHPExcel_IOFactory::createReaderForFile($template); $objPHPExcel = $objReader->load($template); //$objPHPExcel->setActiveSheetIndex(1); $title = $objPHPExcel->getActiveSheet()->getCell(‘A2‘)->getValue(); $title = eval(‘return "‘ . $title . ‘";‘); $objPHPExcel->getActiveSheet()->setCellValue(‘A2‘, $title); $objPHPExcel->getActiveSheet()->setCellValue(‘B5‘, $_GPC[‘time‘][‘start‘]); $objPHPExcel->getActiveSheet()->setCellValue(‘C5‘, $_GPC[‘time‘][‘end‘]); $line_no = 8; foreach($branches as $branch){ $objPHPExcel->getActiveSheet()->setCellValue("A{$line_no}", $branch[‘dist2‘]); $objPHPExcel->getActiveSheet()->setCellValue("B{$line_no}", $branch[‘num‘]+0); $objPHPExcel->getActiveSheet()->setCellValue("C{$line_no}", $branch[‘money‘]+0); $line_no++; } //$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, ‘Excel2007‘); //$objWriter->save(‘myexchel.xlsx‘); // 输出 97-2003 版本的 header(‘Content-Type: application/vnd.ms-excel‘); header(‘Content-Disposition: attachment;filename="‘ . $title . ‘.xls"‘); header(‘Cache-Control: max-age=0‘); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, ‘Excel5‘); $objWriter->save(‘php://output‘); return; exit; }
phpexcel使用实例
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。