/// <summary> /// 数据导出 /// </summary> public void ExportExcel([DefaultValue(-1)] int Stuts, string keywords, string ProvinceId, string CityId, string CountyId) { Am_CollectorBll bll = new Am_CollectorBll(); var ListData = bll.GetPageList(keywords, Stuts, ProvinceId, CityId, CountyId); var newlist = new List <Am_CollectorNew>(); foreach (var item in ListData) { var model = new Am_CollectorNew(); model.Address = item.Address; model.AmCount = item.AmCount.ToString(); model.City = item.City; model.CollectorCode = item.CollectorCode; model.County = item.County; model.CreateTime = item.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); model.LastConnectTime = item.LastConnectTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); model.Province = item.Province; model.Remark = GetDays(item.LastConnectTime.Value) + "天"; model.StatusStr = item.StatusStr; model.URealName = item.URealName; model.UserName = item.UserName; newlist.Add(model); } string[] columns = new string[] { "业主帐号:UserName", "业主姓名:URealName", "采集器编号:CollectorCode", "省:Province", "市:City", "区:County", "地址:Address", "状态:StatusStr", "电表数:AmCount", "创建时间:CreateTime", "上次连接:LastConnectTime", "累积在线时间:Remark" }; DeriveExcel.ListToExcel <Am_CollectorNew>(newlist, columns, "会员数据" + DateTime.Now.ToString("yyyyMMddHHmmss")); }
/// <summary> /// 数据导出 /// </summary> public void ExportExcel([DefaultValue(-1)] int Stuts, string Keyword, string Role) { Ho_PartnerUserBll bll = new Ho_PartnerUserBll(); var ListData = bll.GetPageList(Keyword, Role, Stuts); var newlist = new List <Ho_PartnerUserNew>(); foreach (var item in ListData) { var model = new Ho_PartnerUserNew(); model.Address = item.Address; model.CardCode = item.CardCode; model.CreatTime = item.CreatTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); model.Account = item.Account; model.Money = item.Money.Value.ToString("0.00"); model.Name = item.Name; model.Remark = item.Remark; model.StatusStr = item.StatusStr; model.UserRole = item.UserRole; newlist.Add(model); } string[] columns = new string[] { "姓名:Name", "身份证号:CardCode", "手机号:Account", "角色:UserRole", "余额:Money", "地址:Address", "创建时间:CreatTime", "状态:StatusStr", "备注:Remark" }; DeriveExcel.ListToExcel <Ho_PartnerUserNew>(newlist, columns, "会员数据" + DateTime.Now.ToString("yyyyMMddHHmmss")); }
/// <summary> /// 数据导出 /// </summary> public void ExportExcel(string keywords, [DefaultValue(-1)] int Status, string ProvinceId, string CityId, string CountyId, string BeginTime, string EndTime) { Am_BillBll bll = new Am_BillBll(); var ListData = bll.GetPageList(keywords, Status, ProvinceId, CityId, CountyId, BeginTime, EndTime); var newlist = new List <Am_BillNew>(); foreach (var item in ListData) { var model = new Am_BillNew(); model.Address = item.Address; model.AmmeterCode = item.AmmeterCode; model.BillCode = item.BillCode; model.Cell = item.Cell; model.City = item.City; model.County = item.County; model.Floor = item.Floor; model.Money = item.Money.Value.ToString("0.00"); model.Province = item.Province; model.Room = item.Room; model.StatusStr = item.StatusStr; model.F_U_Name = item.F_U_Name; model.OtherFees = item.OtherFees.Value.ToString("0.00"); model.PayTime = item.PayTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); model.SendTime = item.SendTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); model.T_U_Name = item.T_U_Name; newlist.Add(model); } string[] columns = new string[] { "账单号:BillCode", "电表号:AmmeterCode", "运营商:F_U_Name", "租户:T_U_Name", "状态:StatusStr", "账单金额:Money", "滞纳金:OtherFees", "账单日期:SendTime", "支付日期:PayTime", "省:Province", "市:City", "区:County", "单元:Cell", "楼层:Floor", "房号:Room", "地址:Address" }; DeriveExcel.ListToExcel <Am_BillNew>(newlist, columns, "账单数据" + DateTime.Now.ToString("yyyyMMddHHmmss")); }
public ActionResult TestModuleExcelExport() { DirFileHelper.ClearDirectory("/Areas/ZhangCeModule/UploadFile"); TestMoudleBll tmBll = new TestMoudleBll(); // 1.获取数据集合 List <TestMoudle> list = tmBll.GetTestMoudleAllInfo(CookieHelper.GetCookie("NK")); // 2.设置单元格抬头 // key:实体对象属性名称,可通过反射获取值 // value:Excel列的名称 Dictionary <string, string> cellheader = new Dictionary <string, string> { { "GradeCode", "年级" }, { "ClassCode", "班级编号" }, { "ClassName", "班级名称" }, { "ItemName", "项目名称" }, { "TestTeacher", "测试老师" }, { "TestTime", "测试时间" }, { "TestAddress", "测试地点" }, { "TestMaterial", "测试器材" }, { "TestType", "测试方式(手工/仪器)" }, }; // 3.进行Excel转换操作,并返回转换的文件下载链接 string urlPath = DeriveExcel.ListToExcel2003(cellheader, list, "测试信息模版"); var path = Server.MapPath("~/" + urlPath); var name = Path.GetFileName(path); return(File(path, "application/vnd.ms-excel", name)); }
/// <summary> /// 数据导出 /// </summary> public void ExportExcel(string keywords, [DefaultValue(-1)] int Status, string ProvinceId, string CityId, string CountyId, string BeginTime, string EndTime) { Am_ContractBll bll = new Am_ContractBll(); var ListData = bll.GetPageList(keywords, Status, ProvinceId, CityId, CountyId, BeginTime, EndTime); var newlist = new List <Am_ContractNew>(); foreach (var item in ListData) { var model = new Am_ContractNew(); model.Address = item.Address; model.AmmeterCode = item.AmmeterCode; model.Cell = item.Cell; model.City = item.City; model.County = item.County; model.Floor = item.Floor; model.CreateAddress = item.CreateAddress; model.CreateTime = item.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); model.Province = item.Province; model.Room = item.Room; model.StatusStr = item.StatusStr; model.F_U_Name = item.F_U_Name; model.F_UserName = item.F_UserName; model.UserName = item.UserName; model.U_Name = item.U_Name; newlist.Add(model); } string[] columns = new string[] { "电表表号:AmmeterCode", "租户:UserName", "租户姓名:U_Name", "签订日期:CreateTime", "签订地址:CreateAddress", "状态:StatusStr", "运营商:F_UserName", "运营商姓名:F_U_Name", "省:Province", "市:City", "区:County", "单元:Cell", "楼层:Floor", "房号:Room", "地址:Address" }; DeriveExcel.ListToExcel <Am_ContractNew>(newlist, columns, "合同数据" + DateTime.Now.ToString("yyyyMMddHHmmss")); }
public ActionResult HeBeiStudentTestTableExport() { DirFileHelper.ClearDirectory("/Areas/ZhangCeModule/UploadFile"); DStudent_TestScoreBll tcBll = new DStudent_TestScoreBll(); List <HeBeiStudents> heBeiSList = tcBll.GetHeBeiStudentInfoExport(CookieHelper.GetCookie("NK")); StringBuilder HeBeiHtmlTable = new StringBuilder(); HeBeiHtmlTable.Append("<table>"); HeBeiHtmlTable.Append("<tr><th >序号</th><th>新生来源地(以省内11个设区市为单位)</th><th>性别</th><th>人数</th><th>优秀率</th><th>良好率</th><th>及格率</th><th>总达标率</th></tr>"); string mes = ""; foreach (HeBeiStudents heBeiS in heBeiSList) { mes = mes + string.Format("<tr><th>{0}</th><th>{1}</th><th>{2}</th><th>{3}</th><th>{4}</th><th>{5}</th><th>{6}</th><th>{7}</th></tr>", heBeiS.ID, heBeiS.StudentAddress, heBeiS.StudentSex, heBeiS.StudentCount, heBeiS.Outstanding, heBeiS.Goodrate, heBeiS.PassRate, heBeiS.TotalRate); } HeBeiHtmlTable.Append(mes); HeBeiHtmlTable.Append("</table>"); // 进行Excel转换操作,并返回转换的文件下载链接 string urlPath = DeriveExcel.ExportHtmlTableToExcel(HeBeiHtmlTable.ToString(), "河北新生表"); var path = Server.MapPath("~/" + urlPath); var name = Path.GetFileName(path); return(File(path, "application/vnd.ms-excel", name)); }
/// <summary> /// 数据导出 /// </summary> public void ExportExcel(string keywords, [DefaultValue(-1)] int Status, int ChargeType, string BeginTime, string EndTime) { Am_ChargeBll bll = new Am_ChargeBll(); var ListData = bll.GetPageList(keywords, Status, ChargeType, BeginTime, EndTime); var newlist = new List <Am_ChargeNew>(); foreach (var item in ListData) { var model = new Am_ChargeNew(); model.AmmeterCode = item.AmmeterCode; model.ChargeTypeStr = item.ChargeTypeStr; model.CreateTime = item.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); model.Money = item.Money.Value.ToString("0.00"); model.OrderNumber = item.OrderNumber; model.OutNumber = item.OutNumber; model.PayType = item.PayType; model.StatusStr = item.StatusStr; model.SucTime = item.SucTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); model.UserName = item.UserName; model.U_Name = item.U_Name; newlist.Add(model); } string[] columns = new string[] { "编号:OrderNumber", "外部编号:OutNumber", "电表号:AmmeterCode", "用户:UserName", "姓名:U_Name", "充值类型:ChargeTypeStr", "支付方式:PayType", "充值金额:Moeny", "状态:StatusStr", "充值时间:CreateTime", "成功时间:SucTime" }; DeriveExcel.ListToExcel <Am_ChargeNew>(newlist, columns, "充值数据" + DateTime.Now.ToString("yyyyMMddHHmmss")); }
/// <summary> /// 数据导出 /// </summary> public void ExportExcel([DefaultValue(-1)] int Stuts, string keywords, string ProvinceId, string CityId, string CountyId) { Am_AmDepositBll bll = new Am_AmDepositBll(); var ListData = bll.GetPageList(keywords, Stuts, ProvinceId, CityId, CountyId); var newlist = new List <Am_AmDepositNew>(); foreach (var item in ListData) { var model = new Am_AmDepositNew(); model.Address = item.Address; model.Ammeter_Code = item.Ammeter_Code; model.Cell = item.Cell; model.City = item.City; model.County = item.County; model.CreateTime = item.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); model.CurrMoeny = item.CurrMoeny.ToString(); model.Floor = item.Floor; model.Money = item.Money.Value.ToString("0.00"); model.Province = item.Province; model.Room = item.Room; model.StatusStr = item.StatusStr; model.U_Name = item.U_Name; model.UpdateTime = item.UpdateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); newlist.Add(model); } string[] columns = new string[] { "运营商:U_Name", "电表号:Ammeter_Code", "省:Province", "市:City", "区:County", "地址:Address", "单元:Cell", "楼层:Floor", "房号:Room", "押金时间:CreateTime", "状态:StatusStr", "押金金额:Money", "剩余金额:CurrMoeny", "最后更新时间:UpdateTime" }; DeriveExcel.ListToExcel <Am_AmDepositNew>(newlist, columns, "押金数据" + DateTime.Now.ToString("yyyyMMddHHmmss")); }
/// <summary> /// 数据导出 /// </summary> public void ExportExcel(string keywords, int Stuts, string StartTime, string EndTime) { Am_UserGetMoneyToBankBll bll = new Am_UserGetMoneyToBankBll(); var ListData = bll.GetPageList(keywords, Stuts, StartTime, EndTime); var newlist = new List <Am_UserGetMoneyToBankNew>(); foreach (var item in ListData) { var model = new Am_UserGetMoneyToBankNew(); model.BankAddress = item.BankAddress; model.BankCharge = item.BankCharge.Value.ToString("0.00"); model.BankCode = item.BankCode; model.BankName = item.BankName; model.CreateTime = item.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); model.Money = item.Money.Value.ToString("0.00"); model.PayTime = item.PayTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); model.RealMoney = item.RealMoney.Value.ToString("0.00"); model.Remark = item.Remark; model.StatusStr = item.StatusStr; model.UserName = item.UserName; model.U_Name = item.U_Name; newlist.Add(model); } string[] columns = new string[] { "用户名:UserName", "姓名:U_Name", "提现金额:Money", "手续费:BankCharge", "实际到账:RealMoney", "银行名称:BankName", "银行卡号:BankCode", "开户行:BankAddress", "状态:StatusStr", "提现时间:CreateTime", "支付时间:PayTime", "备注:Remark" }; DeriveExcel.ListToExcel <Am_UserGetMoneyToBankNew>(newlist, columns, "提现列表" + DateTime.Now.ToString("yyyyMMddHHmmss")); }
/// <summary> /// 导出Excell模板 /// </summary> /// <returns></returns> public void GetExcellTemperature(string ImportId) { if (!string.IsNullOrEmpty(ImportId)) { DataTable data = new DataTable(); string DataColumn = ""; string fileName; Baseexceliportbll.GetExcellTemperature(ImportId, out data, out DataColumn, out fileName); DeriveExcel.DataTableToExcel(data, DataColumn.Split('|'), fileName); } }
/// <summary> /// 导出Excel /// </summary> /// <param name="ExportField">要导出字段</param> public void GetDeriveExcel(string ExportField) { string JsonColumn = GZipHelper.Uncompress(CookieHelper.GetCookie("JsonColumn_DeriveExcel")); string JsonData = GZipHelper.Uncompress(CookieHelper.GetCookie("JsonData_DeriveExcel")); string JsonFooter = GZipHelper.Uncompress(CookieHelper.GetCookie("JsonFooter_DeriveExcel")); string fileName = GZipHelper.Uncompress(CookieHelper.GetCookie("FileName_DeriveExcel")); DeriveExcel.JqGridToExcel(JsonColumn, JsonData, ExportField, fileName); //CookieHelper.DelCookie("JsonColumn_DeriveExcel"); //CookieHelper.DelCookie("JsonData_DeriveExcel"); //CookieHelper.DelCookie("JsonFooter_DeriveExcel"); //CookieHelper.DelCookie("FileName_DeriveExcel"); }
public ActionResult StudentScoreManExcelExport() { DirFileHelper.ClearDirectory("/Areas/ZhangCeModule/UploadFile"); DStudent_TestScoreBll tcBll = new DStudent_TestScoreBll(); // 1.获取数据集合 List <StudentScoreExcel> list = tcBll.GetDStudentTestScoreListExport(CookieHelper.GetCookie("NK"), "1"); // 2.设置单元格抬头 // key:实体对象属性名称,可通过反射获取值 // value:Excel列的名称 Dictionary <string, string> cellheader = new Dictionary <string, string> { { "GradeCode", "年级编号" }, { "ClassCode", "班级编号" }, { "ClassName", "班级名称" }, { "StudentCode", "学籍号" }, { "NationCode", "民族代码" }, { "StudentName", "姓名" }, { "StudentSex", "性别(男:1,女:2)" }, { "StudentBornDate", "出生日期" }, { "StudentSource", "学生来源" }, { "StudentIDNumber", "身份证号" }, { "StudentNative", "家庭住址" }, { "Heigh", "身高" }, { "Weight", "体重" }, { "Pulmonary", "肺活量" }, { "FiftyRun", "50米跑" }, { "StandJump", "立定跳远" }, { "SitAndReach", "坐位体前屈" }, { "EightHundred", "800米跑" }, { "ThousandRun", "1000米跑" }, { "MinSupination", "一分钟仰卧起坐" }, { "PullUp", "引体向上" }, }; // 3.进行Excel转换操作,并返回转换的文件下载链接 string urlPath = DeriveExcel.ListToExcel2003(cellheader, list, "学生上报成绩表(男)"); var path = Server.MapPath("~/" + urlPath); var name = Path.GetFileName(path); return(File(path, "application/vnd.ms-excel", name)); }
/// <summary> /// 数据导出 /// </summary> public void ExportExcel(string Keyword) { Am_AmmeterMoneyBll bll = new Am_AmmeterMoneyBll(); var ListData = bll.GetPageList(Keyword); var newlist = new List <Am_AmmeterMoneyNew>(); foreach (var item in ListData) { var model = new Am_AmmeterMoneyNew(); model.Classify = item.Classify.Value == 0?"单费率电价":"其他"; model.FirstMoney = item.FirstMoney.Value.ToString("0.00"); model.Name = item.Name; model.Remark = item.Remark; model.UserName = item.UserName; model.UserRealName = item.UserRealName; newlist.Add(model); } string[] columns = new string[] { "名称:Name", "价格类型:Classify", "费率(元/kwh):FirstMoney", "业主姓名:UserRealName", "业主帐号:UserName", "备注:Remark" }; DeriveExcel.ListToExcel <Am_AmmeterMoneyNew>(newlist, columns, "电价数据" + DateTime.Now.ToString("yyyyMMddHHmmss")); }
public ActionResult ClassInfoExcelExport() { DirFileHelper.ClearDirectory("/Areas/ZhangCeModule/UploadFile"); DStudent_ClassBll scBll = new DStudent_ClassBll(); // 1.获取数据集合 List <DStudent_Class> list = scBll.GetAllStudentClassInfoList(CookieHelper.GetCookie("NK")); // 2.设置单元格抬头 // key:实体对象属性名称,可通过反射获取值 // value:Excel列的名称 Dictionary <string, string> cellheader = new Dictionary <string, string> { { "GradeCode", "年级" }, { "ClassCode", "班级编号" }, { "ClassName", "班级名称" }, }; // 3.进行Excel转换操作,并返回转换的文件下载链接 string urlPath = DeriveExcel.ListToExcel2003(cellheader, list, "班级信息上报表"); var path = Server.MapPath("~/" + urlPath); var name = Path.GetFileName(path); return(File(path, "application/vnd.ms-excel", name)); }
/// <summary> /// 数据导出 /// </summary> public void ExportExcel(string keywords) { Am_AmDepositDetailBll bll = new Am_AmDepositDetailBll(); var ListData = bll.GetPageList(keywords); var newlist = new List <Am_AmDepositDetailNew>(); foreach (var item in ListData) { var model = new Am_AmDepositDetailNew(); model.CreateTime = item.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); model.CurrMoney = item.CurrMoney.Value.ToString("0.00"); model.Mark = item.Mark; model.Money = item.Money.Value.ToString("0.00"); model.UserName = item.UserName; model.U_Name = item.U_Name; newlist.Add(model); } string[] columns = new string[] { "运营商:U_Name", "手机号:UserName", "返还金额:Money", "剩余金额:CurrMoney", "返还时间:CreateTime", "备注信息:Mark" }; DeriveExcel.ListToExcel <Am_AmDepositDetailNew>(newlist, columns, "押金明细数据" + DateTime.Now.ToString("yyyyMMddHHmmss")); }
/// <summary> /// 数据导出 /// </summary> public void ExportExcel([DefaultValue(-1)] int Stuts, string keywords, string Number, string ProvinceId, string CityId, string CountyId) { Am_AmmeterBll bll = new Am_AmmeterBll(); var ListData = bll.GetPageList(keywords, Number, Stuts, ProvinceId, CityId, CountyId); var newlist = new List <Am_AmmeterNew>(); foreach (var item in ListData) { var model = new Am_AmmeterNew(); model.Address = item.Address; model.AmmeterMoney = item.AmmeterMoney.Value.ToString("0.00"); model.AmmeterType_Name = item.AmmeterType_Name; model.AM_Code = item.AM_Code; model.Cell = item.Cell; model.City = item.City; model.Collector_Code = item.Collector_Code; model.County = item.County; model.CreateTime = item.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); model.FirstAlarm = item.FirstAlarm.ToString(); model.Floor = item.Floor; model.Money = item.Money.Value.ToString("0.00"); model.Province = item.Province; model.Room = item.Room; model.StatusStr = item.StatusStr; model.UserName = item.UserName; model.UY_Name = item.UY_Name; model.UY_UserName = item.UY_UserName; model.U_Name = item.U_Name; newlist.Add(model); } string[] columns = new string[] { "电表号:AM_Code", "电表类型:AmmeterType_Name", "价格:AmmeterMoney_Name", "采集器编号:Collector_Code", "租户帐号:UserName", "租户姓名:U_Name", "省:Province", "市:City", "区:County", "单元:Cell", "楼层:Floor", "房号:Room", "地址:Address", "状态:StatusStr", "安装时间:CreateTime", "一级预警:FirstAlarm", "电表余额:Money", "业主帐号:UY_UserName", "业主姓名:UY_Name" }; DeriveExcel.ListToExcel <Am_AmmeterNew>(newlist, columns, "电表数据" + DateTime.Now.ToString("yyyyMMddHHmmss")); }
/// <summary> /// 数据导出 /// </summary> public void ExportExcel(string keywords, string BeginTime, string EndTime) { Am_MoneyDetailBll bll = new Am_MoneyDetailBll(); var ListData = bll.GetPageList(keywords, BeginTime, EndTime); var newlist = new List <Am_MoneyDetailNew>(); foreach (var item in ListData) { var model = new Am_MoneyDetailNew(); model.CreateTime = item.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); model.CurrMoney = item.CurrMoney.Value.ToString("0.00"); model.Money = item.Money.Value.ToString("0.00"); model.OperateTypeStr = item.OperateTypeStr; model.Remark = item.Remark; model.UserName = item.UserName; model.U_Name = item.U_Name; newlist.Add(model); } string[] columns = new string[] { "用户:UserName", "姓名:U_Name", "操作类型:OperateTypeStr", "变动金额:Money", "变动时间:CreateTime", "变动后金额:CurrMoney", "备注:Remark" }; DeriveExcel.ListToExcel <Am_MoneyDetailNew>(newlist, columns, "充值数据" + DateTime.Now.ToString("yyyyMMddHHmmss")); }
/// <summary> /// 数据导出 /// </summary> public void ExportExcel(string Number, string keywords, string BeginTime, string EndTime) { Am_AmmeterOperateLogBll bll = new Am_AmmeterOperateLogBll(); var ListData = bll.GetPageList(keywords, Number, BeginTime, EndTime); var newlist = new List <Am_AmmeterOperateLogNew>(); foreach (var item in ListData) { var model = new Am_AmmeterOperateLogNew(); model.AmmeterCode = item.AmmeterCode; model.CollectorCode = item.CollectorCode; model.CreateTime = item.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); model.OperateTypeStr = item.OperateTypeStr; model.Result = item.Result; model.UserName = item.UserName; model.U_Name = item.U_Name; newlist.Add(model); } string[] columns = new string[] { "采集器:CollectorCode", "电表:AmmeterCode", "操作人:UserName", "操作人姓名:U_Name", "操作类型:OperateTypeStr", "操作结果:Result", "操作时间:CreateTime" }; DeriveExcel.ListToExcel <Am_AmmeterOperateLogNew>(newlist, columns, "电表日志" + DateTime.Now.ToString("yyyyMMddHHmmss")); }
/// <summary> /// 学生信息自定义导出 /// </summary> /// <param name="ExportField"></param> /// <param name="ResultType"></param> /// <returns></returns> public ActionResult StudentOtherExcelExport(string ExportField, string ResultType) { DirFileHelper.ClearDirectory("/Areas/ZhangCeModule/UploadFile"); DStudent_TestScoreBll tcBll = new DStudent_TestScoreBll(); ExportField = ExportField.Substring(0, ExportField.Length - 1); string[] pName = ExportField.Split(','); // 1.获取数据集合 List <StudentScoreExcel> list = tcBll.StudentOtherExport(ResultType, CookieHelper.GetCookie("NK")); // 2.设置单元格抬头 // key:实体对象属性名称,可通过反射获取值 // value:Excel列的名称 Dictionary <string, string> cellheader = new Dictionary <string, string> { }; for (int i = 0; i < pName.Length; i++) { if (pName[i] == "studentcode") { cellheader.Add("StudentCode", "学生学号"); } if (pName[i] == "studentname") { cellheader.Add("StudentName", "学生姓名"); } if (pName[i] == "studentsex") { cellheader.Add("StudentSex", "学生性别"); } if (pName[i] == "studentborndate") { cellheader.Add("StudentBornDate", "出生日期"); } if (pName[i] == "studenthomeaddress") { cellheader.Add("StudentHomeAddress", "学生住址"); } if (pName[i] == "gradecode") { cellheader.Add("GradeCode", "年级编号"); } if (pName[i] == "schoolname") { cellheader.Add("SchoolName", "学院名称"); } if (pName[i] == "schoolcode") { cellheader.Add("SchoolCode", "学院编号"); } if (pName[i] == "classname") { cellheader.Add("ClassName", "班级名称"); } if (pName[i] == "classcode") { cellheader.Add("ClassCode", "班级编号"); } if (pName[i] == "nationcode") { cellheader.Add("NationCode", "民族编号"); } if (pName[i] == "nationname") { cellheader.Add("NationName", "民族名称"); } if (pName[i] == "studentnative") { cellheader.Add("StudentNative", "学生籍贯"); } if (pName[i] == "studentmovetype") { cellheader.Add("StudentMoveType", "异动类型"); } if (pName[i] == "studentidnumber") { cellheader.Add("StudentIDNumber", "学生身份证号"); } if (pName[i] == "studentphone") { cellheader.Add("StudentPhone", "学生电话"); } if (pName[i] == "studentisregister") { cellheader.Add("StudentIsRegister", "是否注册"); } if (pName[i] == "heigh") { cellheader.Add("Heigh", "身高"); } if (pName[i] == "weight") { cellheader.Add("Weight", "体重"); } if (pName[i] == "bmi") { cellheader.Add("BMI", "体重指数"); } if (pName[i] == "bmiscore") { cellheader.Add("BMIScore", "体重指数得分"); } if (pName[i] == "bmilevel") { cellheader.Add("BMILevel", "体重指数级别"); } if (pName[i] == "pulmonary") { cellheader.Add("Pulmonary", "肺活量"); } if (pName[i] == "pulmonaryscore") { cellheader.Add("PulmonaryScore", "肺活量得分"); } if (pName[i] == "pulmonarylevel") { cellheader.Add("PulmonaryLevel", "肺活量级别"); } if (pName[i] == "fiftyrun") { cellheader.Add("FiftyRun", "50米跑"); } if (pName[i] == "fiftyrunscore") { cellheader.Add("FiftyRunScore", "50米跑得分"); } if (pName[i] == "fiftyrunlevel") { cellheader.Add("FiftyRunLevel", "50米跑级别"); } if (pName[i] == "standjump") { cellheader.Add("StandJump", "立定跳远"); } if (pName[i] == "standjumpscore") { cellheader.Add("StandJumpScore", "立定跳远得分"); } if (pName[i] == "standjumplevel") { cellheader.Add("StandJumpLevel", "立定跳远级别"); } if (pName[i] == "sitandreach") { cellheader.Add("SitAndReach", "座位体前屈"); } if (pName[i] == "sitandreachscore") { cellheader.Add("SitAndReachScore", "座位体前屈得分"); } if (pName[i] == "sitandreachlevel") { cellheader.Add("SitAndReachLevel", "座位体前屈级别"); } if (pName[i] == "eighthundred") { cellheader.Add("EightHundred", "800米"); } if (pName[i] == "eighthundredscore") { cellheader.Add("EightHundredScore", "800米得分"); } if (pName[i] == "eighthundredlevel") { cellheader.Add("EightHundredLevel", "800米级别"); } if (pName[i] == "eighthundredaddscore") { cellheader.Add("EightHundredAddScore", "800米加分"); } if (pName[i] == "thousandrun") { cellheader.Add("ThousandRun", "1000米"); } if (pName[i] == "thousandrunscore") { cellheader.Add("ThousandRunScore", "1000米得分"); } if (pName[i] == "thousandrunlevel") { cellheader.Add("ThousandRunLevel", "1000米级别"); } if (pName[i] == "thousandrunaddscore") { cellheader.Add("ThousandRunAddScore", "1000米加分"); } if (pName[i] == "minsupination") { cellheader.Add("MinSupination", "1分钟仰卧起坐"); } if (pName[i] == "minsupinationscore") { cellheader.Add("MinSupinationScore", "1分钟仰卧起坐得分"); } if (pName[i] == "minsupinationlevel") { cellheader.Add("MinSupinationLevel", "1分钟仰卧起坐级别"); } if (pName[i] == "minsupinationaddscore") { cellheader.Add("MinSupinationAddScore", "1分钟仰卧起坐加分"); } if (pName[i] == "pullup") { cellheader.Add("PullUp", "引体向上"); } if (pName[i] == "pullupscore") { cellheader.Add("PullUpScore", "引体向上得分"); } if (pName[i] == "pulluplevel") { cellheader.Add("PullUpLevel", "引体向上级别"); } if (pName[i] == "pullupaddscore") { cellheader.Add("PullUpAddScore", "引体向上加分"); } if (pName[i] == "testresult") { cellheader.Add("TestResult", "测试结果:补测、通过、免测,作弊"); } if (pName[i] == "studenttruescore") { cellheader.Add("StudentTrueScore", "学生最后真是成绩"); } if (pName[i] == "testtype") { cellheader.Add("TestType", "测试类型:正常测试、补测测试"); } if (pName[i] == "createtime") { cellheader.Add("CreateTime", "创建时间"); } if (pName[i] == "updatetime") { cellheader.Add("UpdateTime", "更新时间"); } if (pName[i] == "remark") { cellheader.Add("Remark", "备注"); } } string fuStr = "学生信息自定义导出.xls"; // 3.进行Excel转换操作,并返回转换的文件下载链接 string urlPath = DeriveExcel.ListToExcel2003(cellheader, list, "导出老师体测信息表"); FilePathResult file = new FilePathResult("~/" + urlPath, "application/vnd.ms-excel"); file.FileDownloadName = fuStr; return(file); }
public FileResult GetDeriveExcel(string ExportField, string schoolName, string className, string testTeacher, string studentSex, string testBeginDate, string studentCode, string gradeCode) { DirFileHelper.ClearDirectory("/Areas/ZhangCeModule/UploadFile"); ExportField = ExportField.Substring(0, ExportField.Length - 1); string[] pName = ExportField.Split(','); // 1.获取数据集合 List <DStudent_Test> list = dSTestBll.TestStudentExport(ExportField, schoolName, className, testTeacher, studentSex, testBeginDate, studentCode, gradeCode, CookieHelper.GetCookie("NK")); // 2.设置单元格抬头 // key:实体对象属性名称,可通过反射获取值 // value:Excel列的名称 Dictionary <string, string> cellheader = new Dictionary <string, string> { }; for (int i = 0; i < pName.Length; i++) { if (pName[i] == "studentcode") { cellheader.Add("StudentCode", "学生学号"); } if (pName[i] == "gradecode") { cellheader.Add("GradeCode", "所属年级"); } if (pName[i] == "schoolcode") { cellheader.Add("SchoolCode", "学院编号"); } if (pName[i] == "schoolname") { cellheader.Add("AchoolName", "学院名称"); } if (pName[i] == "classcode") { cellheader.Add("ClassCode", "班级编号"); } if (pName[i] == "classname") { cellheader.Add("ClassName", "班级名称"); } if (pName[i] == "testsetid") { cellheader.Add("TestSetID", "测试设置ID"); } if (pName[i] == "studentname") { cellheader.Add("StudentName", "学生名称"); } if (pName[i] == "studentsex") { cellheader.Add("StudentSex", "学生性别 男:1,女:2"); } if (pName[i] == "testteacher") { cellheader.Add("TestTeacher", "测试老师"); } if (pName[i] == "testaddress") { cellheader.Add("TestAddress", "测试地址"); } if (pName[i] == "beginpradate") { cellheader.Add("BeginPraDate", "开始测试日期"); } if (pName[i] == "beginweek") { cellheader.Add("BeginWeek", "开始测试星期"); } if (pName[i] == "beginpratime") { cellheader.Add("BeginPraTime", "开始测试时间"); } if (pName[i] == "applyfor") { cellheader.Add("ApplyFor", "是否有效 有效:1,无效:2"); } if (pName[i] == "testgroup") { cellheader.Add("Testgroup", "测试组"); } if (pName[i] == "testgroupcode") { cellheader.Add("TestGroupCode", "测试组号"); } if (pName[i] == "testtype") { cellheader.Add("TestType", "测试类型 "); } if (pName[i] == "createtime") { cellheader.Add("CreateTime", "创建时间"); } if (pName[i] == "updatetime") { cellheader.Add("UpdateTime", "更改时间"); } if (pName[i] == "remark") { cellheader.Add("Remark", "备注"); } } string stustr = ""; if (studentSex == "1") { stustr = "男"; } if (studentSex == "2") { stustr = "女"; } string fuStr = "体测信息表(" + testTeacher + "_" + testBeginDate + "_" + stustr + ").xls"; // 3.进行Excel转换操作,并返回转换的文件下载链接 string urlPath = DeriveExcel.ListToExcel2003(cellheader, list, "导出老师体测信息表"); FilePathResult file = new FilePathResult("~/" + urlPath, "application/vnd.ms-excel"); file.FileDownloadName = fuStr; return(file); }