在线求救:=++++++
如题:
=================================================
模版文件代码:
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name></x:Name>
<x:WorksheetOptions>
<x:DisplayGridlines/>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml></head>
<body link=blue vlink=purple leftmargin=0 topmargin=0>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" style="font-size:22px;font-weight:bold">
【$date_start至$date_end 资产负债表 [应收账款] 项目详细列表】
</td>
</tr> 
<tr>
<td>
<table border="1" align="center" width="100%">
<tr  align="center">
<td>公司名称</td>
<td>网上订单号</td>
<td>发票</td>
<td>经销商预存款</td>
<td>提交订单时间</td>
<td>物流确认</td>
<td>物流确认人</td>
<td>物流确认时间</td>
<td>物流送达确认</td>
<td>物流送达人</td>
<td>物流送达时间</td>
<td>销售确认</td>
<td>销售确认人</td>
<td>销售确认时间</td>
<td>仓库确认</td>
<td>仓库确认人</td>
<td>仓库确认时间</td>
<td>财务确认</td>
<td>财务确认人</td>
<td>财务确认时间</td>
<td>备注</td>
</tr>
<!--{loop $tempArrVal $key $value}-->
<tr >
<!--{loop $value $key2 $value2}-->
<td  align="center"><p>$value2</p></td>
<!--{/loop}-->
</tr>
<!--{/loop}-->
</table>
</td>
</tr> 
</table>
</body>
</html>php处理文件:<?phprequire "./include/base.php";$start=$_GET['start'];
$end=$_GET['end'];   //秒数$date_start=date("Y-m-d",$start);
$date_end = date("Y-m-d",$end);//echo $starttime."<>".$endtime;exit();$q = $db->query("select co_id,oid,fapiao,use_vendor_yc,real_time,delivery_confirm,delivery_confirm_id,delivery_confirm_time,delivery_served,served_id,served_time,sales_confirm,post_id,post_time,sto_confirm,sto_confirm_id,sto_confirm_time,fin_confirm,fin_confirm_id,fin_confirm_time,notes from oa_event_sales where post_time>=$start and post_time<=$end");
while($a = $db->fetch_array($q)){
$list[] = $a;
}foreach($list as $key => $val){
$tempArrVal[] = $val;
}/*处理公司名的表
 co_id------------对应oa_company的id。-----对应的数组$list_company_name
*/
$benmu_company_name = $db->query("select id,co_c_name from oa_company");
while($company_name = $db->fetch_array($benmu_company_name)){
$list_company_name[$company_name['id']] = $company_name['co_c_name'];
}
/*处理_id替换的问题
  带_id的都查询oa_login
*/
$benmu_login_name = $db->query("select uid,real_username from oa_login");
while($login_name = $db->fetch_array($benmu_login_name)){
$list_login_name[$login_name['uid']] = $login_name['real_username'];
}
//=======================================================================
//替换
foreach($tempArrVal as $k=>$v){
foreach($v as $kk=>$vv){
if($kk=="co_id"){
$tempArrVal[$k][$kk]=$list_company_name[$vv];
}
if($kk=="delivery_confirm_id" || $kk=="served_id" || $kk=="post_id" || $kk=="sto_confirm_id" || $kk=="fin_confirm_id"){
$tempArrVal[$k][$kk]=$list_login_name[$vv];
}
if($kk=="delivery_confirm_time" || $kk=="real_time" || $kk=="post_time" || $kk=="sto_confirm_time" || $kk=="fin_confirm_time"){
$tempArrVal[$k][$kk]=date("Y-m-d");
}
if($kk=="fapiao"){
if($tempArrVal[$k][$kk]=="0"){
$tempArrVal[$k][$kk]="NO";
}else{
$tempArrVal[$k][$kk]="YES";
}
}
if($kk=="use_vendor_yc"){
if($tempArrVal[$k][$kk]=="0"){
$tempArrVal[$k][$kk]="NO";
}else{
$tempArrVal[$k][$kk]="YES";
}
}
}
}
header("Content-type: application/vnd.ms-excel");header("Content-Disposition: attachment; filename=test.xml"); include template("benmu_check_Excel");?>