php 输出EXCEL 格式不对 我感觉不是EXCEL版本的问题,因为我输出的文件没有表格线,一片白,是不是输出格式不对? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 "\t"换"\r\n",给个例子你参考,我写的$csv = "1,2,3,4\r\n"; $csv.= "1,"; $csv.= "2,"; $csv.= "3,"; $csv.= "中文,"; $csv.="\r\n"; $csvStr .= iconv("UTF-8","GBK//IGNORE",$csv); $csv=''; header("Content-type: application/octet-stream"); header("Accept-Length: ".strlen($csvStr)); header("Content-Disposition: attachment; filename=userrank_".date('ymd')."csv"); echo $csvStr; //给你个例子参考<?phpfunction aircity($code){$sql="select * from aircity where threema='$code'";$r=mssql_query($sql);$rs=mssql_fetch_object($r);$city=trim($rs->city);return $city;}$id=join(',',$_POST['id']);//echo $id."<br>"; $aa=explode(',',$id); foreach($aa as $v){ $bb=explode('~',$v); $i=1; foreach($bb as $vn){ if($i==1){ $gg_id.=$vn."|"; } $i++; } } //echo $gg_id; if($cjr==""){ echo iconv("utf-8","gb2312","订单编号")."\t"; echo iconv("utf-8","gb2312","预定日期")."\t"; echo iconv("utf-8","gb2312","会员名")."\t"; echo iconv("utf-8","gb2312","预订人")."\t"; echo iconv("utf-8","gb2312","机票航程")."\t"; echo iconv("utf-8","gb2312","起飞日期")."\t"; echo iconv("utf-8","gb2312","航班号")."\t"; echo iconv("utf-8","gb2312","票面价")."\t"; echo iconv("utf-8","gb2312","税收")."\t"; echo iconv("utf-8","gb2312","出票状态")."\t"; echo iconv("utf-8","gb2312","总价")."\t"; echo "\n"; $detail=explode('|',$gg_id); foreach($detail as $sid){ if($sid!=""){ $sql="select * from pnrdetail where sid='$sid'"; //echo $sql; $r=mssql_query($sql); $rs=mssql_fetch_object($r); $sid=$rs->sid; $id=$rs->id; //$memberid=$rs->memberid; $kefu=$rs->kefu; $username=$rs->username; $Pnr=$rs->Pnr; $pnum=$rs->pnum; $cjr=$rs->cjr; $hc=$rs->hc; $hb=$rs->hb; $qfdate=$rs->qfdate; $cw=$rs->cw; $price=$rs->price; $shui=$rs->shui; $kou=$rs->kou; $bymoney=$rs->bymoney; $jinprice=$rs->jinprice; $stype=$rs->stype; $content=$rs->content; $sdate=$rs->sdate; $stime=$rs->stime; $cwkou=$rs->cwkou; $printnum=$rs->printnum; $qj=$rs->qj; $chahc=$rs->chahc; $bxprice=$rs->bxprice; $dtotal=$rs->dtotal; $total_dtotal+=$rs->dtotal; echo $sid."\t"; //echo $id."\t"; echo date("Y-m-d",strtotime($sdate))."\t"; echo $username."\t"; //echo $Pnr."\t"; //echo $pnum."\t"; echo $cjr."\t"; //echo $chianses."\t"; $hcPost=explode("|",$hc); foreach($hcPost as $v){ echo aircity(substr($v,0,3))."-".aircity(substr($v,3,6))."|"; } echo "\t"; echo $qfdate."\t"; echo $hb."\t"; //echo $cw."\t"; echo $price."\t"; echo $shui."\t"; echo $stype."\t"; echo $dtotal."\t"; echo "\n"; //echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\n"; // }//if }//循环 }//if($cjr==""){ else{ echo iconv("utf-8","gb2312","订单编号")."\t"; echo iconv("utf-8","gb2312","预定日期")."\t"; echo iconv("utf-8","gb2312","会员名")."\t"; echo iconv("utf-8","gb2312","预订人")."\t"; echo iconv("utf-8","gb2312","机票航程")."\t"; echo iconv("utf-8","gb2312","起飞日期")."\t"; echo iconv("utf-8","gb2312","航班号")."\t"; echo iconv("utf-8","gb2312","票面价")."\t"; echo iconv("utf-8","gb2312","税收")."\t"; echo iconv("utf-8","gb2312","出票状态")."\t"; echo iconv("utf-8","gb2312","总价")."\t"; echo "总价\t"; echo "\n"; $detail=explode('|',$gg_id); foreach($detail as $sid){ if($sid!=""){ $sql="select * from pnrdetail where sid='$sid' order by sid desc "; //echo $sql."<br>"; $r=mssql_query($sql); $rs=mssql_fetch_object($r); $sid=$rs->sid; $id=$rs->id; //$memberid=$rs->memberid; $kefu=$rs->kefu; $username=$rs->username; $Pnr=$rs->Pnr; $pnum=$rs->pnum; $cjr=$rs->cjr; $hc=$rs->hc; $hb=$rs->hb; $qfdate=$rs->qfdate;//起飞日期 $cw=$rs->cw; $price=$rs->price; $shui=$rs->shui; $kou=$rs->kou; $bymoney=$rs->bymoney; $jinprice=$rs->jinprice; $stype=$rs->stype; $content=$rs->content; $sdate=$rs->sdate; $stime=$rs->stime; $cwkou=$rs->cwkou; $printnum=$rs->printnum; $qj=$rs->qj; $chahc=$rs->chahc; $bxprice=$rs->bxprice; $dtotal=$rs->dtotal; $total_dtotal+=$rs->dtotal; echo $sid."\t"; //echo $id."\t"; echo date("Y-m-d",strtotime($sdate))."\t";//substr($sdate,0,10) echo $username."\t"; //echo $Pnr."\t"; //echo $pnum."\t"; echo $cjr."\t"; //echo $chianses."\t"; $hcPost=explode("|",$hc); foreach($hcPost as $v){ echo aircity(substr($v,0,3))."-".aircity(substr($v,3,6))."|"; } echo "\t"; echo $qfdate."\t"; echo $hb."\t"; //echo $cw."\t"; echo $price."\t"; echo $shui."\t"; echo $stype."\t"; echo $dtotal."\t"; echo "\n"; //echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\t"; // echo "\n"; } }//循环 }?> 我看了别人的讲解,了解了我在PHp代码里引用了JS,所以才会这样,把所有的JS去掉,正常了,还是谢谢各位 谁会用JQuery和Zend FrameWork做个购物网站啊 散分,发现一个免费SVN空间,已经注册 FCKeditor如何从数据库读取内容 为什么每次数据查询后只能显示一次结果? 根据时间创建目录的问题 求助!PHP在windows如何读写文件?急用!谢谢!! 帮一下笨猪我啦。。 一个页面显示的问题,帮帮我啊,急 分类+下拉连动问题 服务器的实时结果怎样在浏览器端显示? mysql比较好用的图形化客户端有哪些? windows7 系统 php copy() 函数
$csv.= "1,";
$csv.= "2,";
$csv.= "3,";
$csv.= "中文,";
$csv.="\r\n";
$csvStr .= iconv("UTF-8","GBK//IGNORE",$csv);
$csv='';
header("Content-type: application/octet-stream");
header("Accept-Length: ".strlen($csvStr));
header("Content-Disposition: attachment; filename=userrank_".date('ymd')."csv");
echo $csvStr;
//给你个例子参考
<?php
function aircity($code){
$sql="select * from aircity where threema='$code'";
$r=mssql_query($sql);
$rs=mssql_fetch_object($r);
$city=trim($rs->city);
return $city;
}$id=join(',',$_POST['id']);//echo $id."<br>";
$aa=explode(',',$id);
foreach($aa as $v){
$bb=explode('~',$v);
$i=1;
foreach($bb as $vn){
if($i==1){
$gg_id.=$vn."|";
}
$i++;
}
}
//echo $gg_id; if($cjr==""){
echo iconv("utf-8","gb2312","订单编号")."\t";
echo iconv("utf-8","gb2312","预定日期")."\t";
echo iconv("utf-8","gb2312","会员名")."\t";
echo iconv("utf-8","gb2312","预订人")."\t";
echo iconv("utf-8","gb2312","机票航程")."\t";
echo iconv("utf-8","gb2312","起飞日期")."\t";
echo iconv("utf-8","gb2312","航班号")."\t";
echo iconv("utf-8","gb2312","票面价")."\t";
echo iconv("utf-8","gb2312","税收")."\t";
echo iconv("utf-8","gb2312","出票状态")."\t";
echo iconv("utf-8","gb2312","总价")."\t";
echo "\n";
$detail=explode('|',$gg_id);
foreach($detail as $sid){
if($sid!=""){
$sql="select * from pnrdetail where sid='$sid'";
//echo $sql;
$r=mssql_query($sql);
$rs=mssql_fetch_object($r);
$sid=$rs->sid;
$id=$rs->id;
//$memberid=$rs->memberid;
$kefu=$rs->kefu;
$username=$rs->username;
$Pnr=$rs->Pnr;
$pnum=$rs->pnum;
$cjr=$rs->cjr;
$hc=$rs->hc;
$hb=$rs->hb;
$qfdate=$rs->qfdate;
$cw=$rs->cw;
$price=$rs->price;
$shui=$rs->shui;
$kou=$rs->kou;
$bymoney=$rs->bymoney;
$jinprice=$rs->jinprice;
$stype=$rs->stype;
$content=$rs->content;
$sdate=$rs->sdate;
$stime=$rs->stime;
$cwkou=$rs->cwkou;
$printnum=$rs->printnum;
$qj=$rs->qj;
$chahc=$rs->chahc;
$bxprice=$rs->bxprice;
$dtotal=$rs->dtotal;
$total_dtotal+=$rs->dtotal;
echo $sid."\t";
//echo $id."\t";
echo date("Y-m-d",strtotime($sdate))."\t";
echo $username."\t";
//echo $Pnr."\t";
//echo $pnum."\t";
echo $cjr."\t";
//echo $chianses."\t";
$hcPost=explode("|",$hc);
foreach($hcPost as $v){
echo aircity(substr($v,0,3))."-".aircity(substr($v,3,6))."|";
}
echo "\t";
echo $qfdate."\t";
echo $hb."\t";
//echo $cw."\t";
echo $price."\t";
echo $shui."\t";
echo $stype."\t";
echo $dtotal."\t";
echo "\n";
//echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\n";
//
}//if
}//循环
}//if($cjr==""){
else{
echo iconv("utf-8","gb2312","订单编号")."\t";
echo iconv("utf-8","gb2312","预定日期")."\t";
echo iconv("utf-8","gb2312","会员名")."\t";
echo iconv("utf-8","gb2312","预订人")."\t";
echo iconv("utf-8","gb2312","机票航程")."\t";
echo iconv("utf-8","gb2312","起飞日期")."\t";
echo iconv("utf-8","gb2312","航班号")."\t";
echo iconv("utf-8","gb2312","票面价")."\t";
echo iconv("utf-8","gb2312","税收")."\t";
echo iconv("utf-8","gb2312","出票状态")."\t";
echo iconv("utf-8","gb2312","总价")."\t";
echo "总价\t";
echo "\n";
$detail=explode('|',$gg_id);
foreach($detail as $sid){
if($sid!=""){
$sql="select * from pnrdetail where sid='$sid' order by sid desc ";
//echo $sql."<br>";
$r=mssql_query($sql);
$rs=mssql_fetch_object($r);
$sid=$rs->sid;
$id=$rs->id;
//$memberid=$rs->memberid;
$kefu=$rs->kefu;
$username=$rs->username;
$Pnr=$rs->Pnr;
$pnum=$rs->pnum;
$cjr=$rs->cjr;
$hc=$rs->hc;
$hb=$rs->hb;
$qfdate=$rs->qfdate;//起飞日期
$cw=$rs->cw;
$price=$rs->price;
$shui=$rs->shui;
$kou=$rs->kou;
$bymoney=$rs->bymoney;
$jinprice=$rs->jinprice;
$stype=$rs->stype;
$content=$rs->content;
$sdate=$rs->sdate;
$stime=$rs->stime;
$cwkou=$rs->cwkou;
$printnum=$rs->printnum;
$qj=$rs->qj;
$chahc=$rs->chahc;
$bxprice=$rs->bxprice;
$dtotal=$rs->dtotal;
$total_dtotal+=$rs->dtotal;
echo $sid."\t";
//echo $id."\t";
echo date("Y-m-d",strtotime($sdate))."\t";//substr($sdate,0,10)
echo $username."\t";
//echo $Pnr."\t";
//echo $pnum."\t";
echo $cjr."\t";
//echo $chianses."\t";
$hcPost=explode("|",$hc);
foreach($hcPost as $v){
echo aircity(substr($v,0,3))."-".aircity(substr($v,3,6))."|";
}
echo "\t";
echo $qfdate."\t";
echo $hb."\t";
//echo $cw."\t";
echo $price."\t";
echo $shui."\t";
echo $stype."\t";
echo $dtotal."\t";
echo "\n";
//echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\t";
// echo "\n";
}
}//循环
}
?>