????
恐怕难好像只能用excel的com了
恐怕难好像只能用excel的com了
解决方案 »
- [紧急]下了一个基于PHP的管理系统的压缩包不能运行 求大大帮助
- 寻找PHP合作团队
- 请问如何配子PHP 的executable path?谢谢
- php正则表达式提取html标签的问题
- 表格中大于宽度的英文单词换行除了用<tr style=\"word-break:break-all\">,还有其他办法吗?
- 专业的PHP程序员请进!我有个问题
- PHP模板,请高手赐教!
- 好消息,新文本论坛诞生啦!
- php如何判断一个用户离开某个页面,例如他异常掉线.急啊啊啊啊啊啊啊啊!
- 这种情况一般是怎么回事,请教高手大神指点一下。
- 痛苦.....为什么这样<a href="./post.php?fid=2" target="_black">我要发言</a>不可以在新窗口中打开新得链结!
- 请诸位推荐一些好的项目。
<?
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls");
?>
使用上面的代码,至于EXCEL文件的排版可以用HTML的TABLE来控制。
将下面的代码存为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
?>