protected void btnUpload_Click(object sender, EventArgs e) { string fileName = file.PostedFile.FileName; if (string.IsNullOrEmpty(fileName)) { return; } FileInfo fi = new FileInfo(fileName); string[] exts = new string[] { ".xls", ".xlsx" }; if (!exts.ToList().Exists(ext => ext == fi.Extension)) { this.ltlError.Text = "请上传Excel文件。"; } else { //上传文件 fileName = string.Format("{0}Documents\\TempFolder\\{1:ms}_{2}", this.Request.PhysicalApplicationPath, DateTime.Now, fi.Name); AsposeHelper.CheckPath(fileName); file.PostedFile.SaveAs(fileName); string templateFileName = AsposeHelper.GetTemplateFileName(documentID); DataTable dt = AsposeHelper.GetTemplateDataTable(documentID); BatchUploadResponse response = AsposeHelper.ExcelToDataTable(templateFileName, fileName, dt); if (response.IsVerified) { PersistData(response.Data); } ShowResult(response.GetErrors()); } }