-Hello, World!-
I have an excel file that has data in it that I need to store in a database.
Quick background on this part of the application. A user can download an Excel document with a single worksheet that has a table with headers. They can then paste in the data they have to the template, and upload the document to the website. From there, I need to get it into database.
The problem is that I am unsure how to process the data to get it into the proper form to insert it into the database. I am aware this question has been asked numerous times. However, every example I have found requires the developer to have one of the following conditions: Convert it to a CSV (it must be in an Excel document), create a model to wrap the data in (it can be for any table, and each table can be added dynamically), or upload the Excel document to SQL Server and have it processed there (it must be capable of running on seperate servers).
My question is, what is the best way to get the data from the Excel document, into the database? My first thought is to just create a ton of INSERT
statements, but I feel like there must be a faster way than that. Alternatively, I could use System.Data.SqlClient.SqlBulkCopy
, but I am unsure if that will work for DB2 and Oracle as well as SQLServer, and I am also worried about performance problems that come from having to load all the data out of the Excel document into memory first.
Does anyone have any insight that might help me out?
Thanks!
Edit/Clarification: The code necessary to load things from the Excel document and generate INSERT
statements is fairly straightforward and doesn't even require a lot of effort, especially since I am using EPPlus to get at the data itself. My concern is primarily that I stay within the C#/ASP.NET environment, and that the code I execute is up to industry standards in regards to performance.