Tag: httppostedfilebase

保存并删除使用HttpPostedFileBase保存的Excel文件

我正在上传Excel文件并从中提取数据并将其保存到数据库中。 我正在使用MVC4 .NET框架。 这是我从类的代码: public static void Upload(HttpPostedFileBase File) { NIKEntities1 obj = new NIKEntities1(); MyApp = new Excel.Application(); MyApp.Visible = false; string extension = System.IO.Path.GetExtension(File.FileName); string pic = "Excel" + extension; string path = System.IO.Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Excel"), pic); File.SaveAs(path); MyBook = MyApp.Workbooks.Open(path); MySheet = (Excel.Worksheet)MyBook.Sheets[1]; // Explicit cast is not required here int lastRow = MySheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row; […]