I have this code which export the data from sql database into xls file.
header("Content-Disposition: attachment; filename=\\"test.xls\\"")