Exporting Data to Microsoft Excel - PHP Views : 350
Tagged in : PHP
Send mail vote down 0 vote down 0
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";
?>
By - Rekha, On - 2009-11-13




    Login to add Comments .