예제 #1
0
        /// <summary>
        /// 读取教师信息的Excel表
        /// </summary>
        /// <param name="fileName">Excel表的完整路径</param>
        /// <param name="identity">表名【非工作簿名】</param>
        /// <returns>错误/成功信息</returns>
        public static string ReadTeachersExcel(string fileName, string identity)
        {
            List <string> SheetName = new List <string>();

            SheetName = GetSheetName(fileName);
            string strSQL = "";

            if (SheetName[0] != "Sheet1$")
            {
                return("指定的Excel文件的工作表名不为“Sheet1”,当前的表明为" + SheetName[0]);
            }
            strSQL = "select * from [Sheet1$]";
            ReadExcelToDataSet(fileName, strSQL);

            if (CheckExcelTableTeachers())
            {
                DataTable dt = SplitString.SplitTeacher4DT(ds.Tables["ExcelInfo"]);
                CoursesTOSQLServer(dt, identity);
                return("文件导入成功");
            }
            else
            {
                return("选择的Excel文件中的内容与数据与数据库中的要求不匹配,请确认!");
            }
        }
예제 #2
0
        /// <summary>
        /// 读取课程信息的Excel表
        /// </summary>
        /// <param name="fileName">Excel表的完整路径</param>
        /// <param name="identity">表名【非工作簿名】</param>
        /// <returns>错误/成功信息</returns>
        public static string ReadCoursesExcel(string fileName, string identity)
        {
            List <string> SheetName = new List <string>();

            SheetName = GetSheetName(fileName);

            string strSQL = "";

            if (SheetName[0] != identity + "$")
            {
                return("指定的Excel文件的工作表名不为" + identity + ",当前的表名为" + SheetName[0]);
            }
            strSQL = "select * from [" + SheetName[0] + "]";
            ReadExcelToDataSet(fileName, strSQL);
            if (CheckExcelTableCourses())
            {
                DataTable dt = SplitString.SplitDT(ds.Tables["ExcelInfo"]);
                CoursesTOSQLServer(dt, "TabCourses");
                return("文件导入成功");
            }
            else
            {
                return("选择的Excel文件中的内容与数据库要求不匹配。请确认!");
            }
        }