/// <summary> /// 初使化 /// </summary> private void DataInit() { //初使化条件 pageIndex = Utils.GetInt(Utils.GetQueryStringValue("page"), 1); unionName = EyouSoft.Common.Utils.GetQueryStringValue("unionName"); IList <EyouSoft.Model.SupplierStructure.SupplierOther> list = null; list = csBLL.GetOtherList(pageSize, pageIndex, ref recordCount, EyouSoft.Model.EnumType.CompanyStructure.SupplierType.其他, unionName, CurrentUserCompanyID); if (!(list == null)) { len = list.Count; this.rptList.DataSource = list; this.rptList.DataBind(); list = null; } //设置分页 BindPage(); }
/// <summary> /// 导出Excel /// </summary> public void CreateExcel(string FileName) { IList <EyouSoft.Model.SupplierStructure.SupplierOther> list = null; EyouSoft.BLL.CompanyStructure.CompanySupplier csBLL = new EyouSoft.BLL.CompanyStructure.CompanySupplier(); //导出条件 unionName = EyouSoft.Common.Utils.GetQueryStringValue("unionName"); //获取一条记录,同事获取总记录条数 list = csBLL.GetOtherList(1, 1, ref recordCount, EyouSoft.Model.EnumType.CompanyStructure.SupplierType.航空公司, unionName, CurrentUserCompanyID); //判断记录条数 if (recordCount != 0) { //记录条数>0 获取所有记录 list = csBLL.GetOtherList(recordCount, 1, ref recordCount, EyouSoft.Model.EnumType.CompanyStructure.SupplierType.航空公司, unionName, CurrentUserCompanyID); } Response.Clear(); Response.AppendHeader("Content-Disposition", "attachment;filename=" + FileName + ".xls"); Response.ContentEncoding = System.Text.Encoding.Default; Response.ContentType = "application/ms-excel"; //取得数据表各列标题,各标题之间以\t分割,最后一个列标题后加回车符 StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0}\t{1}\t{2}\t{3}\t{4}\n", "所在地", "单位名称", "联系人", "电话", "传真"); foreach (EyouSoft.Model.SupplierStructure.SupplierOther cs in list) { sb.AppendFormat("{0}\t{1}\t{2}\t{3}\t{4}\n", cs.ProvinceName + " " + cs.CityName, cs.UnitName, cs.SupplierContact == null ? "" : cs.SupplierContact[0].ContactName, cs.SupplierContact == null ? "" : cs.SupplierContact[0].ContactTel, cs.SupplierContact == null ? "" : cs.SupplierContact[0].ContactFax, cs.TradeNum); } Response.Write(sb.ToString()); Response.End(); }