我想在使用 PHPExcel 设置值之前只更改一个字段:
例如001
在电话号码之前设置:
....
if ($result = $DB->execute($sql) or die(mysql_error())) {
$objPHPExcel = new PHPExcel();
$objPHPExcel->getActiveSheet()->setTitle('List');
$rowNumber = 1;
while ($row = mysql_fetch_row($result)) {
$col = 'A';
foreach ($row as $cell) {
$objPHPExcel->getActiveSheet()->setCellValue($col.$rowNumber, .'001 '.$row['phone']);
$objPHPExcel->getActiveSheet()->setCellValue($col . $rowNumber, $cell);
$col++;
}
$rowNumber++;
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="myFile.xls"');
header('Cache-Control: max-age=0');
$objWriter->save('php://output');
exit();
}