我现在有几天问题,无法弄清问题是什么。我感谢任何帮助。所以,我试图将一个列的总数放在使用phpexcel生成的excel文件的单元格中,但是每次使用函数SUM()时生成的excel都会被破坏。函数COUNT(),MIN()等工作得很好。代码如下:
foreach($data as $d)
{
$col = 0; $field_count = 0;
foreach($d as $cell)
{
$sheet->setCellValueByColumnAndRow($col, $row, $cell);
$col++; $field_count++;
}
$row++;
}
$sheet->setCellValue('E'.$row, 'Grand Total:' );
$sheet->setCellValue('F'.$row, '=SUM(F5:F'.($row-1).')');
//$sheet->setCellValue('G'.$row, '=COUNT(F5:F'.($row-1).')');
$objPHPExcel->setActiveSheetIndex(0);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="'.$filename.'"');
header('Cache-Control: max-age=0');
$objWriter->save('php://output');
这是我每次使用SUM时得到的错误: