代码如下:
#region 上传Execl文件
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string NewFileName = string.Empty;
string ErrorMess = UpLoadFile(FileUpload1, ".xls|.xlsx", 1024 * 5, Server.MapPath("/Report/SocialApply/"), 1, out NewFileName);
if (string.IsNullOrEmpty(ErrorMess))
{
Label1.Text = "√文件上传成功";
ViewState["UpLoadFile"] = "/Report/SocialApply/" + NewFileName;
try
{
FileStream file = new FileStream
(Server.MapPath(ViewState["UpLoadFile"] as string),
FileMode.Open, FileAccess.Read,
FileShare.ReadWrite);
DataTable dt1 = FairHR.Util.XmlExcelReport.ReadExcelToDataTable(file, 0, 0);
ViewState.Add("ViewDT", dt1);
GridView1.DataSource = ViewState["ViewDT"] as DataTable;
GridView1.DataBind();
file.Close();
//Maticsoft.Common.MessageBox.ResponseScript(Page, "$.messager.alert('系统提示', '操作成功!', 'info');");
}
catch
新闻热点
疑难解答
图片精选