Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created March 27, 2013 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpfiddle/5253263 to your computer and use it in GitHub Desktop.
Save phpfiddle/5253263 to your computer and use it in GitHub Desktop.
Simple export excel
<?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