<?php
session_start();
ob_start();
if(isset($_POST['EXTRACT'])){
$file = 'outpputfile.xls';
}
?>
<html>
<body>
<form action="" method="post">
<!-- some body here... -->
<!--------------------------------------------------------------------------------------- -->
<table width="700" border="1" cellpadding="0">
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>2</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>3</td>
<td>3</td>
<td>3</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>4</td>
<td>4</td>
<td>4</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>5</td>
<td>5</td>
<td>5</td>
<td>5</td>
</tr>
</table>
<!--------------------------------------------------------------------------------------- -->
<?php
if(isset($_POST['EXTRACT'])){
$content = ob_get_contents();
ob_end_clean();
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); header("Content-type: application/vnd.ms-excel;charset:UTF-8");
header('Content-length: '.strlen($content));
header('Content-disposition: attachment; filename='.basename($file));
echo $content;
exit;
}
?>
<input type="submit" name="EXTRACT" value="EXTRACT TO EXCEL" class="buttons"></td>
<!-- end of some body here... -->
</form>
</body>
</html>
No comments:
Post a Comment