php如何输出excle

来源:百度知道 编辑:UC知道 时间:2024/05/18 02:38:15

将下面的代码存为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&qu