exceluntil:
<?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-mxcel’);
header (“content-disposition: attachment; filename=empllist.xls” );
header (“content-description: php/interba generated data” );
//excel导出开始
function xlsbof() {
echo pack(“ssssss”, 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
return;
}
//excel导出结束
function xlof() {
echo pack(“ss”, 0x0a, 0x00);
return;
}
//导出文字格式
function xlswritenumber($row, $col, $value) {
ec国庆节祝福语最简单的ho pack(“sssss”, 0x203, 14, $row, $col, 0x0);
echo pack(“d”, $value);
return;
}
// 导出文本格式
function xlswritelabel($row, $col, $value ) {
$l = strlen($value);
echo pack(“ssssss”, 0x204, 8 + $l, $row, $col, 0x0, $l);
echo $value;
return;
}
//设置标题值
function ttitlevalue($titlelist){
$leg = count($titlelist);
if($leg !=0){
for ($i =大学男生宿舍 0; $i < $leg; $i++) {
xlswritelabel(0,$i,mb_convert_encoding($titlelist[$i],”gb2312″,”utf-8″));
}
}
}
//excel内容输出设置
function tvalues($datelist){
if(count($datelist) !=0){
for ($i = 0; $i < count($datelist); $i++) {
$list = $datelist[$i];
$leg = count($list);
if ($leg !=0){
for ($j = 0; $j < $leg; $j++) {
$value = $list[$j];
if(is_numeric($value)){//输出类型是数字
xlswritenumber($i+1,$j,$value);
}el{//text类型的输出
xlswritelabel($i+1,$j,mb_convert_encoding($value,”gb2312″,”utf-8″));
}
}
}
}
}
}
?>
调用的php:
<?php
require_once (‘../../common/exceluntil.php’);//导入exceluntil
require_once(‘../adminglobal.inc.php’); //引入后台全局文件
/*权限验证*/
require(abspath . ‘admin/include/head.inc.php’); //引入head内容
require(abspath . ‘admin/include/navigation.inc.php’); //引入head内容
$titlelist = array(‘序号’,’服务噄1�7′,’数据庄1�7′,’用户各1�7′,’备份策略’);//excel标题
$sql = “lect * from zxb_db”;
$result = $mysqlobj->query($sql);
$rows = $mysqlobj->getrows($result);
$datalist = arr王羲之是哪里人ay();
if(count($rows) >0){
for ($i = 0; $i < count($rows); $i++) {
$db = $rows[$i];
$rverid = $db[‘rver_id’];
if($rverid){
$row = $mysqlobj->getbyid(“zxb_db_rver”, $rverid); //取得丄1�7条记彄1�7
$db_rver_name = $row承认 曲婉婷[‘db_rver_name’];
}
$list = array($i+1,$db_rver_name,$db[‘db_name’],$db[‘单数第三人称;ur’],$db[‘bak_strategy’]);
$datalist[$i]=$list;
}
}
xlsbof();//excel导出弄1�7姄1�7
ttitlevalue($titlelist);//导出标题
tvalues($datalist);//导出数据
xlof();//excel导出结束
?>
本文发布于:2023-04-07 06:16:37,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/f6cd37d091e88daa87fc71a9f4840376.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:php导出excel、excelUntil.doc
本文 PDF 下载地址:php导出excel、excelUntil.pdf
留言与评论(共有 0 条评论) |