php生成EXCEL的东东

2016-01-29 14:49 6 1 收藏

php生成EXCEL的东东,php生成EXCEL的东东

【 tulaoshi.com - PHP 】

  可以通过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
?
 

来源:https://www.tulaoshi.com/n/20160129/1494383.html

延伸阅读
标签: Web开发
代码如下: ?php  class html  {      var $dir;        //dir for the htmls(without/)      var $rootdir;    //root of html files(without/):html  &n...
标签: PHP
  <?php /*  Function Written by Nelson Neoh @3/2004.  For those who wants to utilize this code, please do not remove this remark.  If you have done any enhancement to this code, please post the copy at http://www.dev-club.com PHP board.  Thank you. Function usage: calendar(Month,Year) ...
标签: Web开发
如果你的服务器不容许你读他的LOG文件,那你只好停下来分析你的访问者?做你自己的LOG文件吧! 你仅需做的事情是用PHP计算实际的点击次数,没有错误,没有象'304 Not Modified' 和 'Internal Server Error' 一样的错误。你的代码将生成自己的LOG文件。 ?php /* 用户定义变量 */ $logfile = "clf.log"; /*LOG文件写到那里 */ $timezone ...
标签: PHP
现在,上网的人越来越多,许多网友尝试着制作自己的主页,访客计数器是必不可少的一部分。虽然很多网站提供免费的计数器,可毕竟不是自己亲手制作的?有的朋友可能认为它很难,不敢去尝试,其实有了PHP这个工具,它并不难,甚至可以说它很容易。   首先,让我来谈一谈访客计数器的思路:一位访问者浏览此页,服务器(如Apac...
标签: excel 办公软件
打开软件 首先我们要打开我们我们电脑上的excel表格办公软件。实现10-100的整数随机数,我们要用到的就是一个非常好用的公式RandBetwween(bottom,top)。就会生成从bottom最小值到top最大值之间的任意整数。 输入公式 所以我们需要选中单元格然后在单元格中输入这个公式。“==RandBetwween(10,100)”,其实在输入的时候主要输入“...

经验教程

437

收藏

44
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部