zoukankan      html  css  js  c++  java
  • 织梦订单列表导出到excel

    导出效果

    使用说明

    • 可选择导出指定的订单,不选就是导出全部
    • 导出的excle文件按当前时间命名
    • 导出的excel文件请用wps软件打开,office软件下可能会乱码

    1、打开 /dede/shops_operations.php 找到

    else if ($dopost == 'delete')

    在它上面加入

    else if ($dopost == 'out')
    {
    	header("Content-type:application/vnd.ms-excel");
    	header("Content-Disposition:attachment;filename=".date("Y-m-d-H-i-s").".xls");
    	echo "<table><tr>";
    	echo "<th>订单号</th>";
    	echo "<th>商品名称</th>";
    	echo "<th>单价(元/单位)</th>";
    	echo "<th>数量</th>";
    	echo "<th>支付方式</th>";
    	echo "<th>配送费</th>";
    	echo "<th>购买时间</th>";
    	echo "<th>收货人</th>";
    	echo "<th>地址</th>";
    	echo "<th>邮编</th>";
    	echo "<th>联系电话</th>";
    	echo "<th>邮箱</th>";
    	echo "<th>留言</th>";
    	echo "<th>合计(元)</th>";
    	echo "<th>状态</th>";
    	echo "</tr>";
    	$wh = '';
    	if( !empty($nid) )
    	{
    		$nids = explode('`',$nid);
    		foreach($nids as $n)
    		{
    			if($wh=='') $wh = " WHERE o.oid='$n' ";
    			else $wh .= " OR o.oid='$n' ";
    		}
    	}
    
    	$sql = "SELECT o.*,p.title,p.price as uprice,d.dname,u.* FROM #@_shops_orders as o left join #@_shops_products as p on o.oid=p.oid left join #@_shops_delivery as d on d.pid=o.pid LEFT JOIN #@_shops_userinfo AS u ON o.oid=u.oid $wh";
    	$dsql->SetQuery($sql);
    	$dsql->Execute('t');
    	while($arr = $dsql->GetArray('t'))
    	{
    		echo "<tr>";
    		echo "<td>".$arr['oid']."</td>";//订单号
    		echo "<td>".$arr['title']."</td>";//商品名称
    		echo "<td>".$arr['uprice']."</td>";//单价
    		echo "<td>".$arr['cartcount']."</td>";//数量
    		echo "<td>".GetsType($arr['paytype'])."</td>";//支付方式
    		echo "<td>".$arr['dname']."费用:".$arr['dprice']."元</td>";//配送费
    		echo "<td>".GetDateTimeMk($arr['stime'])."</td>";//购买时间
    		echo "<td>".$arr['consignee']."</td>";//收货人
    		echo "<td>".$arr['address']."</td>";//地址
    		echo "<td>".$arr['zip']."</td>";//邮编
    		echo "<td>".$arr['tel']."</td>";//联系电话
    		echo "<td>".$arr['email']."</td>";//邮箱
    		echo "<td>".$arr['des']."</td>";//留言
    		echo "<td>".$arr['priceCount']."</td>";//合计
    		echo "<td>".GetSta($arr['state'])."</td>";//状态
    		echo "</tr>";
    	}
    	echo "</table>";
    	exit();
    }

    2、打开 /dede/shops_operations.htm 找到

    <input type="button" name="b9" value="设为已完成状态" class='np coolbg' style="100" onClick="OkSel();">

    在它下面加入

    <input type="button" name="b9" value="导出选中订单" class='np coolbg' style="100" onClick="OutSel();">

    继续找到

    function PushSel(){

    在它上面加入

    function OutSel()
    {
    	var nid = getCheckboxItem();
    	location.href = "shops_operations.php?dopost=out&nid="+nid;
    }

    完成,看清楚教程,有的是在下面加入有的是在上面加入的。

  • 相关阅读:
    验证LeetCode Surrounded Regions 包围区域的DFS方法
    Qt Package Project 打包发布程序
    [LeetCode] Missing Number 丢失的数字
    [CareerCup] 6.4 Blue Eyes People on Island 岛上的蓝眼人
    [CareerCup] 6.3 Water Jug 水罐问题
    [CareerCup] 6.2 Dominos on Chess Board 棋盘上的多米诺
    [CareerCup] 6.1 Find Heavy Bottle 寻找重瓶子
    [CareerCup] 5.8 Draw Horizonatal Line 画横线
    Print or Cout an Unsigned Char Variable 打印无符号字符
    Kinect 学习链接
  • 原文地址:https://www.cnblogs.com/dedehtml/p/9913837.html
Copyright © 2011-2022 走看看