1

I need some help we are going to import the data from excel to mysql database and we're going to use the MS Interop. We don't know how to start and we do some research about the MS Interop but we don't know how to start. We only now is declare the namespace we don't know what's next.

We found some youtube tutorials but they are using OLedb(if this is right), I hope you can help us!

5
  • Are you sure you need interop? There are easier ways if you're working with .xlsx files. Commented Sep 17, 2017 at 10:42
  • Why? Is there another way to do it? Commented Sep 17, 2017 at 11:00
  • You can use the OpenXML SDK, or an abstraction of it like the ClosedXML library. I believe there's another one called Epplus. Commented Sep 17, 2017 at 11:04
  • I've searched about the OpenXML is this only for creating an excel file? I don't see instruction for importing or something.. Commented Sep 17, 2017 at 11:14
  • It is a complete SDK for MS Office files. It can be complicated, ClosedXML is an abstraction over it to make it easier. You can still do most anything with Excel and there are a lot of examples. Commented Sep 17, 2017 at 11:23

1 Answer 1

2

You can use ExcelDataReader or Microsoft.Office.Interop.Excel as described in this answer, to read data from your sheet, then create a SqlCommand, like insert into myTable (column1, column2) values (1, 'mydata') and execute it over a connection to your MySQL Database.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.