首頁  >  文章  >  後端開發  >  excel表格的35招必學秘技影片 php生成EXCEL的東東

excel表格的35招必學秘技影片 php生成EXCEL的東東

WBOY
WBOY原創
2016-07-29 08:34:28913瀏覽

可以透過PHP來產生EXCEL檔.  teaman翻譯
----------------------------
Excel Functions
- ---------------------------
將下面的程式碼存為excel.php ,然後在頁面中包含進來
然後調用
1. Call xlsBOF()  
2. 將一些內容寫入到xlswritenunber() 或者xlswritelabel()中.
3.然後調用Call xlsEOF()
也可以用fwrite 函數直接寫到伺服器上,而不是用echo 僅在瀏覽器上顯示。
// ----- begin of function library -----
// Excel begin of file header
function xlsBOF() {
   > echo pack(" ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);  
    return;
}
// Excel end of foot footunction; ss", 0x0A, 0x00);
    return;
}
// Function to write a Number (double) into Row, Col
function xlsWriteNumber($Row, $,Number($Row) $,Number($Row)
    echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
    echo pack("d", $Value);
    echo pack("d", $Value);
    echo pack("d", $Value);
   >; / Function to write a label (text) into Row, Col
function xlsWriteLabel($Row, $Col, $Value ) {
    $L = strlen($Value);
  pack sssssecho( , 0x204, 8 + $L, $Row, $Col, 0x0, $L);
    echo $Value;
return;
}
// -----library -----
?>
//  
// To display the contents directly in a MIME compatible browser  
// add the following lines on TOP of your PHP file: header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");     
header ("Pragma: no-cache");   application/x-msexcel');
header ("Content-Disposition: attachment; filename=EmplList.xls" );  
header ("Content-Description: PHP/INTERBASE Generated Data" ); /
// the next lines demonstrate the generation of the Excel stream
//
xlsBOF();   // begin Excel stream
xlsWriteLabel(0,0,"This is a label"); // write a label in A1, use for dates too
xlsWriteNumber(0,1,9999);  // write a number B1
xlsEOF(); // close the stream
?>
xlsEOF(); // close the stream
?>

以上就介紹了excel表格的35招必學秘技影片 php生成EXCEL的東東,包括了excel表格的35招必學秘技影片方面的內容,希望對PHP教程有興趣的朋友有所幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn