[心得] 資料匯出成excel,欄位可以文字型態顯示
不確定大家是不是早就都會了...如果有更好的方法,請各位大大分享吧@@
首先,這個是一個偽excel檔! 我的目的是希望他可以被excel執行,並不要自動
格式化我們的欄位資料。
=================================================================
檔名可以直接用 『xxxx.xls』
優點:excel不會太聰明幫user自動格式化顯示欄位資料
09123456
09654321
像這樣的欄位皆可以正確顯示,而不會被去 "0" 顯示
缺點:不像csv檔一樣,以『,』分割欄位,不利日後將資料匯入其他系統
(但是應該可以透過excel再一次的把資料轉成csv)
下面我會把範例給貼上來,而我們主要要操作的部份是<body>裡面的表格而已
其餘的部份,直接copy來用就可以。其中最主要的是<td class=x125>,加上這個
class才會有效果;不加的話,該欄位就會以excel自型判斷的結果呈現。
原始碼直接貼上來有點亂...
可以參考下列網址這個檔案
http://fs.mis.kuas.edu.tw/~m1097345123/excel.xls
==================================================================
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="" rel="nofollow">http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>無標題文件</title>
<style>
<!--table
@page
{mso-header-data:"&CMultiplication Table\000ADate\: &D\000APage &P";
mso-page-orientation:landscape;}
br
{mso-data-placement:same-cell;}
-->
.xl24
{mso-style-parent:style0;
mso-number-format:"\[TWN\]\[$-404\]y\0022\/\0022m\0022\/\0022d\0022\0022\;\@";}
.xl25
{mso-style-parent:style0;
mso-number-format:"\@";}
</style>
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>第一頁</x:Name>
<x:WorksheetSource Id="1"/>
<x:WorksheetOptions>
<x:Print>
<x:ValidPrinterInfo/>
</x:Print>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml><![endif]-->
</head>
<body>
<table border="1" cellspacing="0" cellpadding="0"
style="font-size:15px;font-family:'新細明體
';border-collapse:collapse;"><tr><td bgcolor="#505050" colspan="5"
align="center"><font size=4 color="#FFFFFF"><B>陳大德 導生聚報表
</B></font></td></tr><tr><td bgcolor="#CCCCCC">主題</td><td bgcolor="#CCCCCC">
導生聚日期時間</td><td bgcolor="#CCCCCC">地點</td><td bgcolor="#CCCCCC">內容
</td><td bgcolor="#CCCCCC">出席狀況</td></tr><tr><td class=xl25>開學前夕聚餐
</td>
<td class=xl25>2009-03-31 18:30</td>
<td class=xl25>我家牛排</td>
<td class=xl25>請各位提早到現場,千萬不要遲到<br>====================<br>特製牛
排130<br>特製豬排120<br>菲力牛排200<br>丁骨230</td>
<td class=xl25>A君<font color="#FF0000">(缺席)</font><BR />B君<font
color="#FF0000">(缺席)</font><BR />C君<font color="#FF0000">(缺席)</font><BR
/></td></tr>
<tr><td class=xl25>期初聚餐</td>
<td class=xl25>2009-04-01 12:30</td>
<td class=xl25>民雄鵝肉</td>
<td class=xl25>可攜帶家眷</td>
<td class=xl25>A君<font color="#FF0000">(缺席)</font><BR />B君<font
color="#FF0000">(缺席)</font><BR /></td></tr>
<tr><td class=xl25>期中聚餐</td>
<td class=xl25>2009-05-15 12:0</td>
<td class=xl25>千葉火鍋</td>
<td class=xl25>每人199元</td>
<td class=xl25>A君<font color="#FF0000">(缺席)</font><BR />B君<font
color="#FF0000">(缺席)</font><BR />C君<font color="#FF0000">(缺席)</font><BR
/></td></tr>
<tr><td class=xl25>期末聚餐</td>
<td class=xl25>2009-06-30 12:0</td>
<td class=xl25>野宴燒烤</td>
<td class=xl25>每人399</td>
<td class=xl25>B君<font color="#FF0000">(缺席)</font><BR />C君<font
color="#FF0000">(缺席)</font><BR /></td></tr>
<tr><td class=xl25>母親節聚會</td>
<td class=xl25>2009-05-10 12:30</td>
<td class=xl25>陶板屋</td>
<td class=xl25>陶板屋</td>
<td class=xl25>A君<font color="#FF0000">(缺席)</font><BR />B君<font
color="#FF0000">(缺席)</font><BR />C君<font color="#FF0000">(缺席)</font><BR
/></td></tr>
<tr><td class=xl25>清民節聚會</td>
<td class=xl25>2009-04-05 12:0</td>
<td class=xl25>學校餐廳</td>
<td class=xl25>學校餐廳</td>
<td class=xl25>A君<font color="#FF0000">(缺席)</font><BR />B君<font
color="#FF0000">(缺席)</font><BR />C君<font color="#FF0000">(缺席)</font><BR
/></td></tr>
<tr><td class=xl25>慶生</td>
<td class=xl25>2009-03-31 18:0</td>
<td class=xl25>校內餐廳</td>
<td class=xl25>校內餐廳</td>
<td class=xl25>B君<BR />A君<font color="#FF0000">(缺席)</font><BR />C君<BR
/></td></tr>
</table></body></html>
>"< 如果大家都不會,請"推"這一篇一下吧
給我優文 給我優文 (>////<) b
--
身為一個Web Designer,當文書處理人員說
『Hey,cjoe 我已經把文件用word處理好了,麻煩依格式幫我轉到網頁上公告』
小cjoe知道....
重新排版的工作來了
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.171.82.105
※ 編輯: cjoe 來自: 118.171.82.105 (04/03 09:08)
推
04/03 10:07, , 1F
04/03 10:07, 1F
→
04/03 10:07, , 2F
04/03 10:07, 2F
→
04/03 10:39, , 3F
04/03 10:39, 3F
→
04/03 10:39, , 4F
04/03 10:39, 4F
→
04/03 10:40, , 5F
04/03 10:40, 5F
→
04/03 10:41, , 6F
04/03 10:41, 6F
※ 編輯: cjoe 來自: 118.171.82.105 (04/03 10:43)
推
04/03 11:02, , 7F
04/03 11:02, 7F
→
04/03 11:03, , 8F
04/03 11:03, 8F
→
04/03 11:03, , 9F
04/03 11:03, 9F
→
04/03 11:04, , 10F
04/03 11:04, 10F
→
04/03 11:04, , 11F
04/03 11:04, 11F
→
04/03 11:05, , 12F
04/03 11:05, 12F
推
04/03 12:22, , 13F
04/03 12:22, 13F
→
04/03 12:23, , 14F
04/03 12:23, 14F
→
04/03 12:24, , 15F
04/03 12:24, 15F
推
04/03 12:30, , 16F
04/03 12:30, 16F
→
04/03 12:30, , 17F
04/03 12:30, 17F
→
04/03 12:30, , 18F
04/03 12:30, 18F
推
04/03 12:33, , 19F
04/03 12:33, 19F
→
04/03 12:33, , 20F
04/03 12:33, 20F
→
04/03 12:34, , 21F
04/03 12:34, 21F
→
04/03 12:37, , 22F
04/03 12:37, 22F
→
04/03 12:37, , 23F
04/03 12:37, 23F
→
04/03 12:38, , 24F
04/03 12:38, 24F
→
04/03 17:29, , 25F
04/03 17:29, 25F
→
04/03 17:30, , 26F
04/03 17:30, 26F
→
04/03 17:31, , 27F
04/03 17:31, 27F
→
04/03 17:31, , 28F
04/03 17:31, 28F
→
04/03 17:32, , 29F
04/03 17:32, 29F
推
04/03 23:29, , 30F
04/03 23:29, 30F