Question ASP.NET Core Blazor Excel Import

raysefo

Well-known member
Joined
Feb 22, 2019
Messages
237
Programming Experience
10+
Hello,

I am new to ASP.NET core blazor. I would like to know if there are some tutorials about importing excel data into SQL database. (The user selects the excel file then uploads it and saved data into the database is displayed on the view.)

Thanks in advance.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
5,251
Location
Chesapeake, VA
Programming Experience
10+
I'm assuming that you are talking about Blazor server, and not Blazor web assembly. Since it's server side, once the file has been uploaded, you would just process the file the way you would as if you were using old fashioned ASP.NET WebForms or ASP.NET MVC.

The difficult part opening the Excel file. If you need to support Excel 2003 files and older, then it the level of difficulty goes up even more.

DO NOT USE the JET or ACE drivers for reading the Excel file. Microsoft intends the JET and ACE drivers for use on the desktop, not server side. There are warnings on Microsoft's download site about this. Most people ignore this warning and then later wonder why their IIS server and/or web app is acting weird.

I suggest using a 3rd party library for reading the Excel files. If you are too cheap to pay for a library, then be prepared to go through the learning curve of the Microsoft OpenXML SDK for reading the Excel 2007 and newer files. For the Office 2003 and older files, you'll need to read through all the documents that the Department of Justice required Microsoft to submit documenting the older COM/OLE document storage format that Office was using. I believe that there is also an open source Java library that was ported to .NET which can read Office documents. My quick scan of that many years ago left me with the impression that it was a poorly documented kludge. It may have gotten better since then.
 
Top Bottom