You are here

網頁直接轉成excel可讀的檔案

基本上一樣用 header 就可達到你要的xls檔
但我用的方法很賤 ^^

一、
將資料內容用依照html的方式輸出至網頁

二、
用header 用 輸出的html內容 直接存為 xls 檔
雖其 source code 是html
但用excel可以打開
因副檔名是xls

header :

if($type=="outport")
{
$fname = output.xls";  <- 指定匯出檔名
header ("Content-disposition: filename=$fname");  <- 指定匯出檔名
header("Content-type: application/octetstream");
header("Pragma: no-cache");
header("Expires: 0");
}

打完收功 呼~~

原文 : http://www.ecstart.com/forum/viewthread.php?tid=11406&extra=page%3D1

Tags: 

Add new comment

Full HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.