Pergunta

I am trying to get data from an excel file to parse to a table in my database. Basically I am trying to read an excel file and copy all the data to a database.

I tried some different methods but did not succeed. I mainly tried to use Reading Excel files from C#

Can someone help me with this.

I am using windows 7 64bit.

Foi útil?

Solução

Use .NET libraries for excel, they are generally easier to use, and doesn't require excel installed on target machine.

NPOI for .xls (Excel 2003 and lower), and EPPlus for xslx (2007+)

Outras dicas

Project -> Add Reference -> LATEST Microsoft.Office.Interop.Excel
And then you have this example on how to access the data in a workbook:
Reading data from excel 2010 using Microsoft.Office.Interop.Excel

I hope this is your solution.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top