protected void btnImport_Click(object sender, EventArgs e) { // 获取Excep文件的完整路径 string strFileName = this.fileExcel.PostedFile.FileName; try { if (strFileName.Substring(strFileName.LastIndexOf('.') + 1) == "xls" || strFileName.Substring(strFileName.LastIndexOf('.') + 1) == "xlsx") { //创建临时文件 string strTempFileName = PublicMethod.CreateTempFile(this.fileExcel, "hytd"); //导入数据 string strReturn = GetAttendanceDetail(strTempFileName); //删除临时文件 PublicMethod.DeleteTempFile("hytd"); //提示信息 if (strReturn != string.Empty) { lblMsg.InnerText = strReturn; } else { lblMsg.InnerText = "导入成功"; PublicMethod.Alert(this, "导入成功"); } } else { lblMsg.InnerText = "您选择的不是Excel文件!"; PublicMethod.Alert(this, "您选择的不是Excel文件!"); } } catch { lblMsg.InnerText = "导入失败!"; PublicMethod.Alert(this, "导入失败"); } }