Reputation: 1
Im using C# and Service based database and I need to import some data from Excel to my database ..How could I possibly do this?? Please help. Thanks a lot.
Upvotes: 0
Views: 455
Reputation: 3886
You can open the excel file with the Excel database driver and read it like any other data source, however this means you need the driver, which isn't installed by default.
However if the sheet only contains data and doesn't need any calculations, you can unzip the XLSX file, and find sheet1.xml (or whatever it's called in your file), open it in your app like any other XML file and import the data.
This is likely to be a much better long term solution, since MS has been trying to kill off the Access database driver for ages.
Also, it's been a while, but I don't believe MS recommends using the MSDE from within a service.
Upvotes: 1
Reputation: 3024
I would recommend you to use OfficeOpenXml.Core.ExcelPackage
or EPPlus
to read/write excel files. Bellow is some links to reference
https://www.c-sharpcorner.com/article/import-and-export-data-using-epplus-core/
Upvotes: 0