IT 개발/PHP
PHP 엑셀로 저장하기
행복구슬
2011. 4. 7. 15:30
1. 일반적인 HTML문 앞에 header 넣기
<?
header( "Content-type: application/vnd.ms-excel; charset=euc-kr");
header( "Content-Disposition: attachment; filename=저장할 파일명" );
header( "Content-Description: PHP4 Generated Data" );
?>
<html>
<head>
</head>
<body>
<table>
<tr>
<td>aaaaaaa</td>
<td>bbbbbbb</td>
<td>ccccccc</td>
</tr>
<tr>
<td>ddddddd</td>
<td>eeeeeee</td>
<td>ffffffffffffffff</td>
</tr>
</table>
</body>
</html>
header( "Content-type: application/vnd.ms-excel; charset=euc-kr");
header( "Content-Disposition: attachment; filename=저장할 파일명" );
header( "Content-Description: PHP4 Generated Data" );
?>
<html>
<head>
</head>
<body>
<table>
<tr>
<td>aaaaaaa</td>
<td>bbbbbbb</td>
<td>ccccccc</td>
</tr>
<tr>
<td>ddddddd</td>
<td>eeeeeee</td>
<td>ffffffffffffffff</td>
</tr>
</table>
</body>
</html>
2. HTML을 변수로 만들어서 출력시키기
<?
header( "Content-type: application/vnd.ms-excel" );
echo("$output");
page_close();
?>
header( "Content-type: application/vnd.ms-excel" );
echo("$output");
page_close();
?>