ecshop 导出exl表格

// 导出订单
if(isset($_POST['export'])){ // 统计金额
$sl = "SELECT SUM(goods_amount) as total from".$ecs->table('depot_order')." where order_id in($order_id)";
$total = $db->getRow($sl);
//print_r($total);exit; // 商品关联订单
$sql = "SELECT o.order_sn,g.goods_name,g.goods_price,g.goods_number,(g.goods_number*g.goods_price) as goods_total FROM ".$ecs->table('depot_order')." AS o,".$ecs->table('depot_goods')." AS g where g.order_id = o.order_id and o.order_id in($order_id)";
$result = $db->getAll($sql); //表格格式
$file_name = '微仓订单';
header("Content-type: application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=$file_name.xls"); /* 文件标题 */
// echo ecs_iconv(EC_CHARSET, 'GB2312', $_REQUEST['start_date']. $_LANG['to'] .$_REQUEST['end_date']. $_LANG['sales_list']) . "\t\n"; /* 商品名称,订单号,商品数量,销售价格,销售日期 */
echo ecs_iconv(EC_CHARSET, 'GB2312', $_LANG['goods_name']) . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', $_LANG['order_sn']) . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', '数量') . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', '商品单价') . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', '商品总价') . "\t";
echo "\n"; foreach ($result AS $key => $value)
{
echo ecs_iconv(EC_CHARSET, 'GB2312', $value['goods_name']) . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', $value['order_sn'] ) . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', $value['goods_number']) . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', $value['goods_price']) . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', $value['goods_total']) . "\t";
echo "\n";
} echo "\n";
echo ecs_iconv(EC_CHARSET, 'GB2312', '统计') . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', $total['total']) . "\t"; exit;
}
上一篇:iOS打电话、发短信、发邮件功能开发


下一篇:c# 发邮件功能