Answer the question
In order to leave comments, you need to log in
How to properly format the total row in PHPExcel?
Let's say we need such a sign:
Additionally, we need filters in the header, I do everything like this:
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$active_sheet = $objPHPExcel->getActiveSheet();
$active_sheet->setCellValue('A3', '№');
$active_sheet->setCellValue('B3', 'Товар');
$active_sheet->setCellValue('C3', 'Цена');
$active_sheet->setAutoFilter('A3:C3');
$active_sheet->setCellValue('A4', '1');
$active_sheet->setCellValue('B4', 'Товар 1');
$active_sheet->setCellValue('C4', '200');
$active_sheet->setCellValue('A5', '2');
$active_sheet->setCellValue('B5', 'Товар 2');
$active_sheet->setCellValue('C5', '500');
$active_sheet->setCellValue('A6', '3');
$active_sheet->setCellValue('B6', 'Товар 3');
$active_sheet->setCellValue('C6', '120');
$active_sheet->setCellValue('A7', '4');
$active_sheet->setCellValue('B7', 'Товар 4');
$active_sheet->setCellValue('C7', '245');
$active_sheet->setCellValue('A8', '5');
$active_sheet->setCellValue('B8', 'Товар 5');
$active_sheet->setCellValue('C8', '130');
$active_sheet->setCellValue('A9', 'Итог');
$active_sheet->setCellValue('C9', '=SUM(C4:C8)');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
header("Content-Type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename=simple.xls");
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question