Example #1
0
        public static string ExportAllClassStudent(string teachingClassID, int oCID, bool isHistory)
        {
            if (!UserService.OC_IsRole(oCID))
            {
                return("");
            }

            string  fileUrl = "";
            DataSet ds      = new DataSet();
            List <ExportOCClassStudent> occlassstudentlist = new List <ExportOCClassStudent>();
            OCClassBLL oCClassBLL = new OCClassBLL();

            occlassstudentlist = oCClassBLL.ExportAllClassStudent(teachingClassID, oCID, isHistory);
            foreach (var item in occlassstudentlist)
            {
                ds.Tables.Add(IES.Common.ListToDateUtil.ListToDataTable <OCClassStudent>(item.ClassStudent));
            }

            string sheetNames = "";
            string headerName = "学号,姓名,专业,行政班,年级";

            for (int i = 0; i < ds.Tables.Count; i++)
            {
                sheetNames += "政班" + i + ds.Tables[i].Rows[0]["TeachingClassName"] + ",";
                ds.Tables[i].Columns.Remove("EntryDate");
                ds.Tables[i].Columns.Remove("MOOCLearningPace");
            }
            if (!string.IsNullOrEmpty(sheetNames))
            {
                sheetNames = sheetNames.Substring(0, sheetNames.Length - 1);
            }

            try
            {
                fileUrl = NPOIHandler.ExportDataSetToExcelMVC(ds, "StudentAll.xls", sheetNames, headerName);
            }
            catch (Exception e)
            {
                fileUrl = "";
            }
            return(fileUrl);
        }