protected void xueqibiaobao_Click(object sender, EventArgs e)//学生学期考勤信息生成方法
{
string str8 = "select xueqi,classname,xuehao,stname,leixing,count(*) as cishu from tb_kaoqin where xueqi='" +
xueqitjb.SelectedValue + "' and classname='" +
xueqibanji.Text + "' group by xueqi,classname,xuehao,stname,leixing";
DataSet st = db.GetDs(str8);
StringWriter sw = new StringWriter();
sw.WriteLine("学期,班级,学号,姓名,类型,累计");
foreach (DataRow dr in st.Tables[0].Rows)
{
sw.Write(dr[0].ToString() + ",");
sw.WriteLine(dr[1].ToString() + "," + dr[2].ToString() + "," + dr[3].ToString() + "," + dr[4].ToString() + "," + dr[5].ToString());
}
sw.Close();
string name = System.DateTime.Today.ToString("yyyy年MM月dd日") + ".csv";
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(name));
Response.ContentType = "application/ms-excel";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.Write(sw);
Response.End();
}