[HttpPost] public ActionResult Cal() { string ExcelName = System.DateTime.Now.ToString("yyyyMMddHHmmss");//表名yyyyMMddHHmmss DataSet dsCal = new DataSet(); if (Request.Files.Count != 0) { HttpPostedFileBase fb = Request.Files[0]; // Stream sr = Request.Files["fileName"].InputStream; //获取到这个文件流 string fileName = fb.FileName; //获取到文件名 xx.xls string extenSion = Path.GetExtension(fileName); //文件后缀 .xls if (extenSion.Equals(".xls") || extenSion.Equals(".xlsx")) { //一:上传服务器 fb.SaveAs(Server.MapPath("~/App_Data/Excel/Model.xls")); //二:将Excel表格转换为DadaSet数据集 dsCal = GetDataSet(fb.FileName); //将五张基本表存入数据库中 获取年月 string year = Request.Form["selYear"].ToString(); string month = Request.Form["selMon"].ToString(); FillDataToDB(year, month, dsCal); } else { //提示文件输入格式不正确 } } return View("Index"); }