Hello friends, I'm getting an excel like HttpRequestPostedFileBase from a form of Asp.NET , but I need to open it, I know I can store the file and send it to me
Workbook sheet = excel.Workbooks.Open ("path / file.xls");
The path of the file to open it, but in this case I want to open it and confirm its contents before saving it. So I want to open it, until now I have this, but it asks me the name with the route, does anyone know if I can open it in this same way or some other library?
if (Request.Files.Count > 0) {
var file = Request.Files[0];
string value = Request.Form["lstlistaCuentas"].ToString();
string[] keys = Request.Form.AllKeys;
string cuenta = form["lstlistaCuentas"].ToString();
string banco = form["lstBancos"].ToString();
string extension = System.IO.Path.GetExtension(file.FileName);
string fname = System.IO.Path.GetFileName(file.FileName);
if (extension == ".xls" || extension == ".xlsx") {
switch (banco) {
//banamex
case ("1"):
string fn = file.FileName;
if (!fn.Contains("BX")) {
return View("Error");
} else {
Application excel = new Application();
Workbook sheet = excel.Workbooks.Open(" quiero mandar unicamente el HttpRequestPostedFileBase ");
Worksheet x = excel.ActiveSheet as Worksheet;
_Worksheet xlWorksheet = sheet.Sheets[1];
Excel.Range xlRange = xlWorksheet.UsedRange;
}
break;
}
}
}