3

What is the fastest way of reading all data rows from a specific Excel Workbook Sheet into an ADO.NET DataTable using C#. The Excel Workbook will be approximately 30MB.

I do not want to use ODBC as i will have issues with getting it installed on the server machine.

My preference is a solution that uses the StreamReader Class, but any solution that doesn't use StreamReader is welcome except one that uses ODBC.

StackTrace
  • 9,190
  • 36
  • 114
  • 202
  • You could try the free version of GemBox .NET library for importing records directly to DataTable.. http://www.gemboxsoftware.com/spreadsheet/overview – Kokulan Eswaranathan Mar 07 '13 at 12:36

1 Answers1

1

in case ms office is installed on the server, the fastest way would be to export the excel sheet into a CSV file and then using file IO to import it into your database.

you could open excel via COM Interop and export the workbook to CSV. others here on stackoverflow discussed this proceeding: Save an excel file to a csv file in C# code

i've got the experience that getting data out of excel directly via com interop is very slow. excel exports csv really fast instead.

[edit] a very good office wrapper is NetOffice. It works similar like the COM Interop interface but with more speed and more function: http://netoffice.codeplex.com/

as you prefer stream reader, there's an excel binary reader on codeplex too: http://exceldatareader.codeplex.com/ [/edit]

Community
  • 1
  • 1
ceth
  • 734
  • 5
  • 15