Exporting Data to Microsoft Excel
by Rekha[ Edit ] 2009-11-13 11:40:01
You can export content from a php page to an excel spreadsheet as follows,
<form action = "excel.php" method = "post">
<input type = "hidden" name = "body" value = "">
<input type = "submit" name = "submit" Value = "Export to excel">
</form>
In excel.php file,
$fn=$_POST['body'];
header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=excel.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$fn";
?>