using system.web;
public class sdsavecsv
{
///
/// 构造函数
///
/// httpresponse对象
public sdsavecsv(httpresponse response)
{
this.response = response;
}
///
/// 输入出文件
///
/// 文件名称
/// 文件内容
///成功/失败
public bool outfile(string fullpath, string content)
{
bool retvalue = false;
try
{
this.response.buffer = true;
this.response.clear();
this.response.charset = system.text.encoding.default.bodyname;
this.response.contentencoding = system.text.encoding.getencoding("gb2312");//gb2312用excel打开时,没有乱码。
this.response.appendheader("content-disposition", "attachment;filename=" + fullpath);
this.response.contenttype = "application/ms-excel";
this.response.output.write(content);
this.response.flush();
this.response.end();
retvalue = true;
}
catch (exception ex)
{
retvalue = false;
throw new applicationexception(string.format("输出数据csv出错:{0}",fullpath), ex);
}
return retvalue;
}
}
//===============================以下为调用方法
stringbuilder sbfile = new stringbuilder();
sbfile.append("商户,蛋名称,蛋id,时间,累计领蛋人数,累计发蛋量");
sbfile.appendline();//换行
foreach (datarow row in ds.tables[0].rows)
{
sbfile.appendformat("{0},{1},{2},{3},{4},{5}", eggmerchants1.merchantname, row["eggname"], row["rowid"], row["date"], row["pep"], row["num"]);
sbfile.appendline();
}
new sdsavecsv(this.response).outfile(string.format("fetchegg({0}).csv",datetime.now), sbfile.tostring());
敢达决战官方正版 安卓版v6.7.9
下载敢达决战 安卓版v6.7.9
下载像素火影骨架佐助 (Perseverance Fire Shadow)手机版v1.16
下载要塞英雄 安卓版v33.20.0-39082670-Android
下载梦想城镇vivo最新版本 安卓版v12.0.1
梦想城镇vivo版是这款卡通风模拟经营类手游的渠道服版本,玩
怦然心动的瞬间 安卓版v1.0
怦然心动的瞬间是一款真人向的恋爱互动游戏,在游戏中玩家将扮演
曼尼汉堡店游戏 安卓版v1.0.3
曼尼汉堡店是一款非常好玩的精品恐怖类型冒险游戏,在这款游戏中
现代总统模拟器去广告版 安卓版v1.0.46
现代总统模拟器是一款休闲养成类游戏,可能对于不少的玩家来说都
现代总统模拟器付费完整版 安卓版v1.0.46
现代总统模拟器高级版在商店是需要付费的,相对于普通版本,高级