简体   繁体   English

连接到大型Excel文件非常慢

[英]Connection to large excel file is very slow

I have a very large excel file, it has about one milion rows and have size about 400MB. 我有一个很大的Excel文件,它有大约一百万行,大小约为400MB。 I need to estabilish some System.Data.IDbConnection to this file. 我需要为此文件建立一些System.Data.IDbConnection。 For now, i tried two aproaches: 1) 现在,我尝试了两个方法:1)

System.Data.OleDb.OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0;Data Source='D:\\file.xls';Extended Properties='Excel 12.0;HDR=YES;IMEX=1';");

2) 2)

System.Data.Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=<FILE>;ReadOnly=True;Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\"")

Both connections work just fine for small files (25MB). 两种连接都适用于小文件(25MB)。 But even for 25MB file, opening connection take about 4seconds. 但是,即使是25MB的文件,打开连接大约也需要4秒。

When I use 350MB file, this simple command: 当我使用350MB文件时,此简单命令:

connection.Open();

takes more than 3 minutes and i cannot use so slow connection. 需要超过3分钟,我不能使用这么慢的连接。

Is there any free sollution to get fast IDbConnection for reading large excel file? 是否有任何免费的解决方案来获取快速的IDbConnection来读取大型Excel文件? Thanks for any help. 谢谢你的帮助。

Try a different aproach, maybe if you use an access database, where de excel sheets are linked, you can gain time. 尝试不同的方法,也许如果您使用的是将de excel表链接到的Access数据库,则可以节省时间。 The connection between access and excel is wierd but in many cases faster than import Excel files. access和excel之间的连接比较麻烦,但是在许多情况下,它们比导入Excel文件要快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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