简体   繁体   中英

How to read all data rows in a specific Excel sheet into an ADO.NET Datatable with out using ODBC in C#

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.

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM