标签:
/** * 写excel方法 */ function writeExcel($tabArr, $dataArr,$path) { require_once CODE_BASE2 . ‘/util/phpexcel/PHPExcel.php‘; $objPHPExcel = new PHPExcel(); $objSheet = $objPHPExcel->setActiveSheetIndex(0); //写表头 $index = ‘A‘; foreach ($tabArr as $value) { $objSheet->setCellValue($index .‘1‘, $value); $index++; } //写数据 $i = 2; foreach ($dataArr as $key => $line) { $index = ‘A‘; foreach($line as $val){ $objSheet->setCellValue($index.$i, $val); $index++; } $i++; } $objWriter = PHPExcel_IOFactory:: createWriter($objPHPExcel, ‘Excel2007‘); $objWriter->save($path); }
标签:
原文地址:http://www.cnblogs.com/zhudongchang/p/5063987.html