[英]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#. 使用C#从特定Excel工作簿表读取ADO.NET DataTable的所有数据行的最快方法是什么。 The Excel Workbook will be approximately 30MB.
Excel工作簿大约为30MB。
I do not want to use ODBC as i will have issues with getting it installed on the server machine. 我不想使用ODBC,因为我将在服务器计算机上安装它时遇到问题。
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. 我的偏好是使用StreamReader类的解决方案,但是除了使用ODBC之外,任何不使用StreamReader的解决方案都是受欢迎的。
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. 如果服务器上安装了ms office,最快的方法是将Excel工作表导出为CSV文件,然后使用文件IO将其导入数据库。
you could open excel via COM Interop and export the workbook to CSV. 您可以通过COM Interop打开excel并将工作簿导出为CSV。 others here on stackoverflow discussed this proceeding: Save an excel file to a csv file in C# code
stackoverflow上的其他人讨论了这个过程: 将一个excel文件保存到C#代码中的csv文件中
i've got the experience that getting data out of excel directly via com interop is very slow. 我已经获得了通过com interop直接从excel获取数据的经验非常慢。 excel exports csv really fast instead.
excel非常快速地输出csv。
[edit] a very good office wrapper is NetOffice. [编辑]一个非常好的办公包装是NetOffice。 It works similar like the COM Interop interface but with more speed and more function: http://netoffice.codeplex.com/
它的工作方式类似于COM Interop界面,但速度更快,功能更多: http : //netoffice.codeplex.com/
as you prefer stream reader, there's an excel binary reader on codeplex too: http://exceldatareader.codeplex.com/ [/edit] 如你更喜欢流阅读器,在codeplex上也有一个excel二进制阅读器: http : //exceldatareader.codeplex.com/ [/ edit]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.