I have a project in asp.net mvc that upload excel file into action.I am going to directly read data from HttpPostedFileBase as FileStream and convert it to object without saving file in server.
[HttpPost]
public ActionResult AddBulkIndividual(HttpPostedFileBase file)
{
Application excel = new Application();
excel.Visible = false;
excel.Workbooks.Open(filePath);
_Workbook workbook = excel.ActiveWorkbook;
_Worksheet worksheet = workbook.ActiveSheet;
…..
what can i put instead filepath to read from filestream directly?
I don’t believe the default Excel library can read a file from a stream. You could possibly write the stream to a file first and open that, or use a library like ExcelDataReader.
If you need to do a ton more with the Excel format, I’d check out OfficeWriter, which can open from streams plus much more. It is probably overkill for your needs, however. Disclaimer: I’m one of the engineers who built a prior version.