Exporting Data to Microsoft Excel

by Rekha 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";
?>

Tagged in:

1021
like
0
dislike
0
mail
flag

You must LOGIN to add comments