Codice PHP:
<?php

$filename 
"file_excel.xls";
header ("Content-Type: application/vnd.ms-excel");
header ("Content-Disposition: attachment; filename=$filename");

echo 
"testo1";
echo 
"testo2";

?>