简体   繁体   English

如何在C#中使用ODBC读取特定Excel工作表中的所有数据行到ADO.NET数据表中

[英]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.

相关问题 如何将excel文件一列的所有内容读入数组C#? 不使用 ADO.net 方法 - How to read all contents of a column of excel file into an array C#? Without using ADO.net approach 使用C#从Excel到数据库ADO.net的导入数据中选择空格表 - select spacific sheet in import data from Excel to database ADO.net using C# 如何使用C#ADO.NET更新Excel行? - How to update a excel row using C# ADO.NET? C#/ ADO.NET-在数据表中使用SetField时会跳过行吗? - C#/ADO.NET - Rows being skipped while using SetField in datatable? 如何使用C#和ADO.NET从Excel中读取小数和日期 - How to read decimal and dates from Excel with C# and ADO.NET ADO.net如何使用C#和连接的模型在页面加载时将特定数据库表单元格中的数据绑定到转发器控件上? - ADO.net how to bind data from specific database table cell to a repeater control on page load using C# & the connected model? 使用 ADO.NET 在代码隐藏 C# 中使用 select 语句获取所有行数据 - Get all the row data with select statement in codebehind C# using ADO.NET 如何使用Ado.net C#插入项目列表? - How to insert list of items Using Ado.net C#? 如何在 C# 中使用 ADO.NET 执行 SQL 命令? - How to execute SQL command using ADO.NET in C#? 如何使用ADO.NET在C#中从SQL Server检索数据? - How to retrieve data from SQL Server in C# using ADO.NET?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM