protected void ExportButton_Click(object sender, EventArgs e) { UserCouponSearchInfo userCouponSearch = new UserCouponSearchInfo(); userCouponSearch.CouponId = RequestHelper.GetQueryString <int>("CouponID"); userCouponSearch.UserId = RequestHelper.GetQueryString <int>("UserID"); userCouponSearch.GetType = RequestHelper.GetQueryString <int>("GetType"); userCouponSearch.Number = RequestHelper.GetQueryString <string>("Number"); userCouponSearch.IsUse = RequestHelper.GetQueryString <int>("IsUse"); List <UserCouponInfo> userCouponList = UserCouponBLL.SearchList(userCouponSearch); StringBuilder sb = new StringBuilder(); sb.Append("ID\t优惠券编号\t密码\t获取类型\t所属用户\t是否使用\n"); foreach (UserCouponInfo userCoupon in userCouponList) { sb.Append(userCoupon.Id.ToString() + "\t#" + userCoupon.Number + "\t" + userCoupon.Password + "\t" + userCoupon.GetType + "\t" + userCoupon.UserName + "\t" + ShopCommon.GetBoolString(userCoupon.IsUse) + "\n"); } Response.Clear(); Response.Buffer = true; Response.Charset = "GB2312"; Response.AppendHeader("Content-Disposition", "attachment;filename=userCoupon.xls"); Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); Response.ContentType = "application/ms-excel"; Response.Write(sb.ToString()); Response.End(); }