I am using PHPExcel
with Codeigniter in a fairly simple way:
$this->load->library('PHPExcel/Classes/PHPExcel');
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setTitle("Gastos")->setDescription("Descripcion de gastos");
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'NOMBRE GASTO');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'value_1');
$i = 1;
foreach($q->result() as $row){
$i++;
$objPHPExcel->getActiveSheet()->setCellValue('A'.$i, utf8_encode($row->name));
$objPHPExcel->getActiveSheet()->setCellValue('B'.$i, $row->value_1);
}
Where the variable $q
is a query, I'm sure that $row->name
and $row->value_1
correctly bring the data, to finish I have this other code:
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="GASTOS.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
My problem is that when downloading the excel it shows me this warning and the document in the following way:
I can not find the error nor can I correct this even if I try ...