private
void
Button2_Click(
object
sender, System.EventArgs e)
... {
DateTime dt;
if(this.Search_Time.Text ==null || this.Search_Time.Text =="")
...{
dt = DateTime.Now;
}
else
...{
dt = Convert.ToDateTime(this.Search_Time.Text.ToString());
}
this.UpStartDay = dt.ToString("yyyy-MM-dd");
string Nums = Admin_Bonus.Get_Count(this.UpStartDay,1);//总碰数的统计
string ZZHD = Admin_Bonus.Get_Count(this.UpStartDay,2);//组织互动的统计
string FDDD = Admin_Bonus.Get_Count(this.UpStartDay,3);//辅导对等的统计
string HJ = Convert.ToDouble(System.Math.Round(Convert.ToDouble(ZZHD),2)+System.Math.Round(Convert.ToDouble(FDDD),2)).ToString();
DataSet ds = new DataSet();
ds = Admin_Bonus.Get_DateSet(this.UpStartDay);
this.BonusList.DataSource = ds;
this.BonusList.DataBind();
Response.AddHeader("Content-Type", "application/vnd.ms-excel");
Response.AddHeader("Content-Disposition", "attachment;filename=Day~JJMX~"+this.UpStartDay.ToString()+".xls");
Response.Charset = "";
ResponseEncoding="utf-8";//以此编码模式导出才不会出现乱码
//关闭 ViewState
EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();//将信息写入字符串
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);//在WEB窗体页上写出一系列连续的HTML特定字符和文本。
//此类提供ASP.NET服务器控件在将HTML内容呈现给客户端时所使用的格式化功能
//获取control的HTML
hw.WriteLine("<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#a9cb34" class="table">");
hw.WriteLine("<tr height="18" bgcolor="#f5fce0">");
hw.WriteLine("<td colspan=8 width="71%" align="center" class="xtd">各项统计</td>");
hw.WriteLine("<td width="5%" align="center" class="xtd">"+Nums.ToString()+"</td>");
hw.WriteLine("<td width="9%" align="center" class="xtd">"+ZZHD.ToString()+"</td>");
hw.WriteLine("<td width="8%" align="center" class="xtd">"+FDDD.ToString()+"</td>");
hw.WriteLine("<td width="7%" align="center" class="xtd">"+HJ.ToString()+"</td>");
BonusList.RenderControl(hw);//将DATAGRID中的内容输出到HtmlTextWriter对象中
// 把HTML写回浏览器
Response.Write(tw.ToString());
Response.End();
}
... {
DateTime dt;
if(this.Search_Time.Text ==null || this.Search_Time.Text =="")
...{
dt = DateTime.Now;
}
else
...{
dt = Convert.ToDateTime(this.Search_Time.Text.ToString());
}
this.UpStartDay = dt.ToString("yyyy-MM-dd");
string Nums = Admin_Bonus.Get_Count(this.UpStartDay,1);//总碰数的统计
string ZZHD = Admin_Bonus.Get_Count(this.UpStartDay,2);//组织互动的统计
string FDDD = Admin_Bonus.Get_Count(this.UpStartDay,3);//辅导对等的统计
string HJ = Convert.ToDouble(System.Math.Round(Convert.ToDouble(ZZHD),2)+System.Math.Round(Convert.ToDouble(FDDD),2)).ToString();
DataSet ds = new DataSet();
ds = Admin_Bonus.Get_DateSet(this.UpStartDay);
this.BonusList.DataSource = ds;
this.BonusList.DataBind();
Response.AddHeader("Content-Type", "application/vnd.ms-excel");
Response.AddHeader("Content-Disposition", "attachment;filename=Day~JJMX~"+this.UpStartDay.ToString()+".xls");
Response.Charset = "";
ResponseEncoding="utf-8";//以此编码模式导出才不会出现乱码
//关闭 ViewState
EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();//将信息写入字符串
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);//在WEB窗体页上写出一系列连续的HTML特定字符和文本。
//此类提供ASP.NET服务器控件在将HTML内容呈现给客户端时所使用的格式化功能
//获取control的HTML
hw.WriteLine("<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#a9cb34" class="table">");
hw.WriteLine("<tr height="18" bgcolor="#f5fce0">");
hw.WriteLine("<td colspan=8 width="71%" align="center" class="xtd">各项统计</td>");
hw.WriteLine("<td width="5%" align="center" class="xtd">"+Nums.ToString()+"</td>");
hw.WriteLine("<td width="9%" align="center" class="xtd">"+ZZHD.ToString()+"</td>");
hw.WriteLine("<td width="8%" align="center" class="xtd">"+FDDD.ToString()+"</td>");
hw.WriteLine("<td width="7%" align="center" class="xtd">"+HJ.ToString()+"</td>");
BonusList.RenderControl(hw);//将DATAGRID中的内容输出到HtmlTextWriter对象中
// 把HTML写回浏览器
Response.Write(tw.ToString());
Response.End();
}