구슬이네 IT & Media / IT 와 미디어를 바라봅니다




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>




2. HTML을 변수로 만들어서 출력시키기




<? 
header( "Content-type: application/vnd.ms-excel" );
echo("$output");
page_close();
 ?>