if the report table is already in a database
this is how i did it:
<a href='export.php?pg_src=$pg_src'><img src='download.gif' border='0'></a>
then in export.php put the header:
<?header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: inline; filename=\"tablename.xls\"");
include "access.php";
$q="select * from ext_resources where dept='$pg_src'";
$r=mysql_query($q);
mysql_pconnect ("localhost", "xxx", "xxx"); //connect to database
mysql_select_db ("xx") or die ("Unable to select database");
$q="select * from tablename where report='$report_key'";
$r=mysql_query($q);
echo ("Item#". "\t" ..."\n");
while
($array_exp=mysql_fetch_array($r)) {
echo ($array_exp["item_num"]. "\t" ... "\n");
}//end while