Need to be able to read an Excel file uploaded using FileUploadControl in ASP.NET. The solution will be hosted on a server. I do not want to store the Excel file on the server. I would like to directly convert the excel content into a dataset or a datatable and utilize.
Below are the two solutions I already found but would not work for me.
-
LINQTOEXCEL – This method works when you have an excel file on your local machine and you are running your code on the local machine. In my case, the user is trying to upload an excel file from his local machine using a webpage hosted on a server.
-
ExcelDataReader – I am currently using this one, but this is a third party tool. I cannot move this to our customer. Also if a row/column intersection is carrying a formula, then that row/column intersection’s data is not being read into the dataset.
Most of the suggestions i found on google and StackOverflow work when both the excel and the .NET solution are on the same machine. But in mine, I need it to work when the solution is hosted on a server, and users are trying to upload excel using the hosted webpage on their local machine.
If you have any other suggestions, could you please let me know?
You can use the
InputStreamproperty of theHttpPostedFileto read the file into memory.Here’s an example which shows how to create a
DataTablefrom theIO.Streamof aHttpPostedFileusingEPPlus:Here’s the VB.NET version:
For the sake of completeness, here’s the aspx: