Array to Excel 2007 using PHPExcel
PHPExcel has a built-in method for setting cells from an array in a single step:
$data = array(
array ('Name', 'Surname'),
array('Schwarz', 'Oliver'),
array('Test', 'Peter')
);
$objPHPExcel->getActiveSheet()->fromArray($data, null, 'A1');
for this I would use the function
$objPHPExcel->getActiveSheet()->SetCellValueByColumnAndRow($column, $row, $text)
and run the foreach on the arrays indexes. Columns start at 0, rows at 1.