有人可以告诉我我的代码有什么问题,因为它导出标题确定但是我缺少导出的1条记录。非常感谢
$rowNumber = 1; //start in cell 1
while ($row = mysql_fetch_assoc($result)) {
$col = 'A'; // start at column A
// returns title row
if ( $rowNumber == 1 ){
$headers = array_keys($row);
foreach($headers as $header) {
$objPHPExcel->getActiveSheet()->setCellValue($col.$rowNumber,$header);
$col++;
}
$rowNumber++;
}else{ //returns content rows
$col = 'A';
$rowNumber
foreach($row as $cell) {
$objPHPExcel->getActiveSheet()->setCellValue($col.$rowNumber,$cell);
$col++;
}
$rowNumber++;
}
}
$objPHPExcel->getActiveSheet()->removeColumn('A',3);