Code
protected void btnExportDate_Click(object sender, EventArgs e)
{
/*客户端的文件创建
FileStream file = new FileStream(@"c:\newFile.txt", FileMode.OpenOrCreate);
StreamWriter strW = new StreamWriter(file, Encoding.UTF8);
strW.Write("aaaaaaa");
strW.Flush();
strW.Close();
file.Close();
*/
Response.Clear();
//attachment 参数表示作为附件下载,可以改成online在线打开
//filename=FileFlow.xls 制定输出文件的名称,注意其扩展名和制定文件类型相符,可以为:.doc .xls .txt .htm
Response.AppendHeader("Content-Disposition", "attachment;filename=EOL_" + DateTime.Now.Ticks + ".xls");
//编码格式
//Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
Response.ContentEncoding = System.Text.Encoding.Default;
//Response.ContentType制定文件类型,可以为:application/ms-excel,application/ms-word ,application/ms-txt,application/ms-html或其他浏览器可直接支持的文档
Response.ContentType = "application/ms-excel";
//*gvwOut.EnableViewState = false;
//*System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
//*System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
//将目标数据绑定到输入流输出
//this 表示输出本页,也可以绑定GridView,或其他支持 obj.RenderControl() 属性的控件
//*gvwOut.RenderControl(oHtmlTextWriter);
//*this.DataBind.RenderControl(oHtmlTextWriter);
//*Response.Write(oStringWriter.ToString());
DataTable dt = BLLManage<vW_UserHomeDetail>.GetDataTable(" AND HomeType=" + Convert.ToByte(HomeType.GZWM));
Response.Write("家庭域名" + "\t" + "登录帐号" + "\t" + "部门名称" + "\t" + "地域归属" + "\t" + "真实姓名" + "\t" + "联系电话" + "\t" + "安全邮箱" + "\t" + "用户性别" + "\n");
foreach (DataRow i in dt.Rows)
{
string str = "";
for (int j = 0; j < i.ItemArray.Length-2; j++)
{
str += i[j].ToString() + "\t";
}
Response.Write(str);
Response.Write("\n");
}
Response.Flush();
Response.End();
}
protected void btnExportDate_Click(object sender, EventArgs e)
{
/*客户端的文件创建
FileStream file = new FileStream(@"c:\newFile.txt", FileMode.OpenOrCreate);
StreamWriter strW = new StreamWriter(file, Encoding.UTF8);
strW.Write("aaaaaaa");
strW.Flush();
strW.Close();
file.Close();
*/
Response.Clear();
//attachment 参数表示作为附件下载,可以改成online在线打开
//filename=FileFlow.xls 制定输出文件的名称,注意其扩展名和制定文件类型相符,可以为:.doc .xls .txt .htm
Response.AppendHeader("Content-Disposition", "attachment;filename=EOL_" + DateTime.Now.Ticks + ".xls");
//编码格式
//Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
Response.ContentEncoding = System.Text.Encoding.Default;
//Response.ContentType制定文件类型,可以为:application/ms-excel,application/ms-word ,application/ms-txt,application/ms-html或其他浏览器可直接支持的文档
Response.ContentType = "application/ms-excel";
//*gvwOut.EnableViewState = false;
//*System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
//*System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
//将目标数据绑定到输入流输出
//this 表示输出本页,也可以绑定GridView,或其他支持 obj.RenderControl() 属性的控件
//*gvwOut.RenderControl(oHtmlTextWriter);
//*this.DataBind.RenderControl(oHtmlTextWriter);
//*Response.Write(oStringWriter.ToString());
DataTable dt = BLLManage<vW_UserHomeDetail>.GetDataTable(" AND HomeType=" + Convert.ToByte(HomeType.GZWM));
Response.Write("家庭域名" + "\t" + "登录帐号" + "\t" + "部门名称" + "\t" + "地域归属" + "\t" + "真实姓名" + "\t" + "联系电话" + "\t" + "安全邮箱" + "\t" + "用户性别" + "\n");
foreach (DataRow i in dt.Rows)
{
string str = "";
for (int j = 0; j < i.ItemArray.Length-2; j++)
{
str += i[j].ToString() + "\t";
}
Response.Write(str);
Response.Write("\n");
}
Response.Flush();
Response.End();
}