php生成EXCEL的东东

卧龙岗人士

卧龙岗人士

2016-01-29 14:49

php生成EXCEL的东东,php生成EXCEL的东东
  可以通过PHP来产生EXCEL档.  teaman翻译
----------------------------
Excel Functions
----------------------------
将下面的代码存为excel.php ,然后在页面中包括进来

然后调用
1. Call xlsBOF()  
2. 将一些内容写入到xlswritenunber() 或者 xlswritelabel()中.
3.然后调用 Call xlsEOF()

也可以用 fwrite 函数直接写到服务器上,而不是用echo 仅仅在浏览器上显示。
   


<?php
// ----- begin of function library -----
// Excel begin of file header
function xlsBOF() {
    echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);  
    return;
}
// Excel end of file footer
function xlsEOF() {
    echo pack("ss", 0x0A, 0x00);
    return;
}
// Function to write a Number (double) into Row, Col
function xlsWriteNumber($Row, $Col, $Value) {
    echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
    echo pack("d", $Value);
    return;
}
// Function to write a label (text) into Row, Col
function xlsWriteLabel($Row, $Col, $Value ) {
    $L = strlen($Value);
    echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
    echo $Value;
return;
}
// ----- end of function library -----
?

//  
// To display the contents directly in a MIME compatible browser  
// add the following lines on TOP of your PHP file:

<?php
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");     
header ('Content-type: 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
?
 
展开更多 50%)
分享

猜你喜欢

php生成EXCEL的东东

PHP
php生成EXCEL的东东

php不用COM生成excel文件

Web开发
php不用COM生成excel文件

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

php 不用COM 生成excel文件

PHP
php 不用COM 生成excel文件

php生成WAP页面

PHP
php生成WAP页面

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

PHP生成HTML的技术原理

Web开发
PHP生成HTML的技术原理

PHP生成静态页面详解

PHP
PHP生成静态页面详解

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

在字符串中把网址改成超级链接

在字符串中把网址改成超级链接

Macromedia给FlashMX升级

Macromedia给FlashMX升级
下拉加载更多内容 ↓