可以通过PHP来产生EXCEL档. teaman翻译
----------------------------
Excel Functions
----------------------------
将下面的代码存为excel.php ,然后在页面中包括进来
然后调用
1. Call xlsBOF()
2. 将一些内容写入到xlswritenunber() 或者 xlswritelabel()中.
3.然后调用 Call xlsEOF()
也可以用 fwrite 函数直接写到服务器上,而不是用echo 仅仅在浏览器上显示。
1
2// ----- begin of function library -----
3// Excel begin of file header
4function xlsBOF() {
5echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
6return;
7}
8// Excel end of file footer
9function xlsEOF() {
10echo pack("ss", 0x0A, 0x00);
11return;
12}
13// Function to write a Number (double) into Row, Col
14function xlsWriteNumber($Row, $Col, $Value) {
15echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
16echo pack("d", $Value);
17return;
18}
19// Function to write a label (text) into Row, Col
20function xlsWriteLabel($Row, $Col, $Value ) {
21$L = strlen($Value);
22echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
23echo $Value;
24return;
25}
26// ----- end of function library -----
//
// To display the contents directly in a MIME compatible browser
// add the following lines on TOP of your PHP file:
1
2header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
3header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
4header ("Cache-Control: no-cache, must-revalidate");
5header ("Pragma: no-cache");
6header ('Content-type: application/x-msexcel');
7header ("Content-Disposition: attachment; filename=EmplList.xls" );
8header ("Content-Description: PHP/INTERBASE Generated Data" );
9//
10// the next lines demonstrate the generation of the Excel stream
11//
12xlsBOF(); // begin Excel stream
13xlsWriteLabel(0,0,"This is a label"); // write a label in A1, use for dates too
14xlsWriteNumber(0,1,9999); // write a number B1
15xlsEOF(); // close the stream