直接以xsl格式输出ecshop的数据
2009-08-12 15:16 来源:www.chinab4c.com 作者:ecshop专家
最近要帮朋友把ecshop中的一些数据给导成xls格式。还真麻烦。不过找了段代码,还着好用,下面贴出来。
<?
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls");
/*
$ip ="localhost";
$db = "uc";
$user = "root";
$pwd = "root";
*/
$ip ="localhost";
$db = "shopuc";
$user = "shopuc";
$pwd = "##RFV##uc";
$con = mysql_connect($ip,$user,$pwd);
mysql_query("set names 'GBK'");
mysql_select_db($db);
$re = mysql_query("select * from uc_members order by uid desc");
$str = '';
while ($r = mysql_fetch_array($re)) {
echo iconv("UTF-8","GBK",$r['username'])."\t";
echo iconv("UTF-8","GBK",$r['email'])."\t\n";
}
?>
<?php
$ip ="localhost";
$db = "shopuc";
$user = "shopuc";
$pwd = "##RFV##uc";
$con = mysql_connect($ip,$user,$pwd);
mysql_query('set names "utf8"');
mysql_select_db($db);
$re = mysql_query("select * from uc_members order by uid desc");
mysql_query("set names 'UTF8'");
$fp = fopen('file.csv', 'w');
while ($v = mysql_fetch_array($re)) {
fputcsv($fp, array(iconv("UTF-8","GBK",$v['username']),$v['email']));
}
fclose($fp);
?>
<A href="file.csv">x</a>
来源:中国B4C电子商务
最近更新
常用插件
- ecshop红包修改成满多少减
我们在长期使用ecshop的时候,我们可以发现。ecshop的红包是一个非常强...
- ecshop分类树中统计商品数
最近忙于开发其他项目,在不少朋友不断要求和催促的情况下,做出了该小...
- ecshop通用红包编码
很多时候,为了结合促销,必须扩展一下ecshop的红包功能。ecshop的红包...
- ecshop降价通知登记插件
ecshop降价通知登记插件,主要是为了方便某些客户,对商品价格要求比...
- ecshop购物车功能改进[插件
ecshop购物车功能改进[插件套餐]主要是我们最近开发工作和开发项目中。...