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());
茶杯头甜蜜终章dlc 官方手机版v1.0.0.3
下载火柴人传说暗影格斗内置菜单 最新版v3.0.1
下载荒野乱斗测试服 安卓版v61.10.3
下载荒野乱斗彩虹服 安卓版v61.10.3
下载寒霜启示录 安卓版v1.25.10
寒霜启示录是一款生存模拟游戏,不少玩家可能对于末日都有着自己
末日城堡免广告版 安卓最新版v0.7.1
末日城堡免广告版是一款非常好玩的模拟经营类游戏,内部可以不看
甜蜜人生模拟器 最新版v1.4.5
甜蜜人生模拟器是一款非常好玩的模拟恋爱手游,玩家在这里能够对
武器锻造师内置功能菜单 v10.4
武器锻造师内置菜单版是游戏的破解版本,在该版本中为玩家提供了
开放空间overfield 安卓版v1.0.5
开放空间Overfield是一款箱庭养成经营手游,让你在广阔