With results from a MySQL database, nothing fancy:
$position="phone_list";
$contents = "";
$result = getPeople($position, array('first_name','last_name','position_type','phone','location','lab','labext'));
$filename ="excelreport.xls";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-type: application/ms-excel");
header("Content-Disposition: attachment; filename={$filename} ");
header("Content-Transfer-Encoding: binary ");
while ($row=mysql_fetch_array($result,MYSQL_ASSOC)) {
$contents = str_replace("’", "'", $row['last_name']) . " \t";
$contents .= str_replace("’", "'", $row['first_name']) . " \t";
$contents .= find_alias($row['position_type']) . " \t";
$contents .= str_replace("519-824-4120 x", "", $row['phone']) . " \t";
$contents .= "{$row['location']} \t";
$contents .= "{$row['lab']} \t";
$contents .= "{$row['labext']} \t";
$contents .= "\n";
echo $contents;
}