You can eliminate the nested foreach loop by changing
foreach ($data as $rowArray) {
$columnID = 'A';
foreach ($rowArray as $columnValue) {
$objPHPExcel->getActiveSheet()->setCellValue($columnID . $rowID, $columnValue);
$columnID++;
}
$rowID++;
}
to
foreach ($data as $rowArray) {
$objPHPExcel->getActiveSheet()->fromArray($rowArray, null, 'A'. $rowID++);
}
or even simply
$objPHPExcel->getActiveSheet()->fromArray($data, null, 'A2');
And eliminate
$objPHPExcel->getActiveSheet()->setAutoFilter('A1:A1');
because it's meaningless setting autofiltering on a single cell, but will add overhead