EXCEL

會跳個格式不符的警告,不用管它照開就是了!!

超簡單!

<?php
//=== 可以先mark起來不輸出,在網頁上看資料 ===
$file="excel.xls";
header("Content-type: application/vnd.ms-excel");           //文件內容為excel格式
header("Content-Disposition: attachment; filename=$file;"); //將PHP轉成下載的檔案指定名稱與副檔名.xls


echo '<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">'."\n";
// 最後這一段還有一種版本可用 http://www.w3.org/TR/1999/REC-html401-19991224/
// 不過 xmlns:v 就要移除 

echo '<head><meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">'."\n";
//=========================================

 ?>
<style> 
<!--table
/* must  */
  {mso-displayed-decimal-separator:"\.";
  mso-displayed-thousand-separator:"\,";}

/* 這下面可有可無 看個人要怎麼設定  */
/*  範例: */
@page
    {mso-header-data:"&C財團法人\000A財產清冊";
    margin:.75in .7in .75in .7in;
    mso-header-margin:.3in;
    mso-footer-margin:.3in;}
ruby
    {ruby-align:left;}
rt
    {color:windowtext;
    font-size:9.0pt;
    font-weight:400;
    font-style:normal;
    text-decoration:none;
    font-family:新細明體, serif;
    mso-font-charset:136;
    mso-char-type:none;
    display:none;}
/*大標題*/
.xl157338
    {
    padding:20px;
    padding-bottom:30px;
    color:black;
    font-size:50px;
    font-family:標楷體,新細明體, serif;
    text-align:center;
    border: none;
    border-bottom-style: groove;
    }
/*小標題*/
.xl157344
    {
    font-family:新細明體, serif;
    font-size:16px;
    text-align:center;
    }
/*其他*/
.xl157343
    {
    font-family:新細明體, serif;
    text-align:center;
    }
.xl65
    {

    }
-->
</style>
</head>

<body link=blue vlink=purple> <!-- must -->

<div align=center x:publishsource="Excel"> <!-- must -->

 <!-- must 下面 自由花灰 -->

 <!-- 預設是這樣 -->
<table border=0 cellpadding=0 cellspacing=0 width=72 style='border-collapse:
 collapse;table-layout:fixed;width:54pt'>
 <col class=xl65 width=72 style='width:54pt'>

 <!--  也可以不管它拉
<table  border=1 >
 -->

              <thead>
                    <tr>
                      <td   class=xl157338 colspan=5 > XXX目錄</td>
                     </tr>
                    <tr>
                      <th width="100" class=xl157344 rowspan=2 >文字</th>
                     </tr>
              </thead>
              <tbody>
                <tr>
                    <td class=xl157343 >
                        789789
                    </td>
                </tr>
              </tbody>
            </table>
        </div>
    </body>
</html>

results matching ""

    No results matching ""