The small php code below gives me the result of a query in column A, B, Q in excel. The problem now is that I need to make an arrangement or cycle in which it is traversed according to the column in the that is found to fill the other columns of the C: P. Claro making use of another query not the same at first.
$i = 5;
while ($fila = $total->fetch_array()) {
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A'.$i, $fila['gasto'])
->setCellValue('B'.$i, $fila['lunes'])
->setCellValue('Q'.$i, utf8_encode($fila['factura']));
$i++;
}