Created
March 27, 2013 10:30
-
-
Save phpfiddle/5253263 to your computer and use it in GitHub Desktop.
Simple export excel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$html = '<table border=1> | |
<tr> | |
<td>1</td> | |
<td>2</td> | |
<td>3</td> | |
<td>4</td> | |
<td>5</td> | |
</tr> | |
</table>'; | |
if(isset($_POST['excel'])) { | |
header('Content-type: application/ms-excel'); | |
header('Content-Disposition: attachment; filename=foo.xls'); | |
echo $html; | |
return true; | |
} | |
?> | |
<form method='post'> | |
<table> | |
<tr><td><?php echo $html ?></td></tr> | |
<tr><td><input type='submit' name='excel' value='Export' /></td></tr> | |
</table> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment