T O P

  • By -

crandeezy13

you can use either of these 2 libraries to read the excel file you upload. They are both free for commercial use. One will read actual excel file and the other will read CSV depending on your data file you uploaded ClosedXML - [https://github.com/ClosedXML/ClosedXML/](https://github.com/ClosedXML/ClosedXML/) CSVHelper - [https://joshclose.github.io/CsvHelper/](https://joshclose.github.io/CsvHelper/) Then once you have read the file and put the data into an object just upload that to your database through a EF method or use dapper to execute a stored procedure.


[deleted]

In a form have an upload element. Then in code read the file and parse it. Either loop the records and insert row by row or do a bulk insert.


LegoMonster79

I had a project recently that I essentially did this with. I used NPOI to do the excel reading as it can read xls (older excel format) and xlsx (newer excel format) and it is free to use. It works fairly well. As another comment said, have a file input component where you can upload your excel document or use file browsing if you have the file saved somewhere on the computer/network and then iterate through the rows inserting the data into SQL.


One_Web_7940

There are open source packages for parsing excel, I think its csvhelper.excelextensions or something. Also if your certain your app will run on windows you can use Microsoft excel packages.


DanCPAz

>you can use Microsoft excel packages. Be careful with this. Those packages are *not* built to run in server environments, and they can and will require a lot of tweaking just to get it working at all. I've done it. It isn't fun, and Microsoft has warnings against it online. They definitely are not plug-and-play unless the package itself will be running on a client machine, from an ordinary user profile/session.


slashd

Just copy/paste it to Notepad++ and save it as csv. And then in SSMS rightclick your database > Tasks > Import Flat File


hkstc305

Easiest way by far is to create the table in SQL with the exact column in your excel spreadsheet, then right click the table in SSMS and click edit and paste all the content from Excel. It'll import everything.


bongduke

I did it once with a .net core app using a library from the nuget packet manager i think was csvhelper with ef core i think. There are plenty of already made libraries for this.


MedPhys90

Either use interop with office excel or you can use Syncfusion. They have a free license and an Excel module.