protected void btnImport_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(fudPath.PostedFile.FileName)) { ShowMessage("请选择需要上传的文件"); } else { try { var savePath = Service.FileService.Upload(fudPath, "BasePolicy", "xlsx?", int.MaxValue); this.lblWarnInfo.Text = "文件已经成功上传至服务器"; try { DataSet data = NPOIExcelHelper.ImportDataSetFromExcel(fudPath.PostedFile.InputStream, 0); dt = data.Tables[0]; this.dataSource.DataSource = data.Tables[0]; this.dataSource.DataBind(); this.upload.Visible = false; this.confirm.Style.Add(HtmlTextWriterStyle.Display, ""); } catch (Exception ex) { Service.LogService.SaveExceptionLog(ex); } } catch (Exception ex) { this.lblWarnInfo.Style.Add(HtmlTextWriterStyle.Color, "red"); this.lblWarnInfo.Text = ex.Message; } } }