如何读取超过 65535 行的 Excel 2007 电子表格?
这是我的连接字符串的样子。
m_conn = new OleDbConnection(String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=" + (char)34 + "Excel 12.0;HDR=YES" + (char)34, m_fileName));
当我进行选择时,我只得到 65535 行,但我知道 Excel 电子表格至少有 100,000 行。我如何阅读其余的行。注意我必须使用 OLEDB,目前没有第三方工具。
非常感谢!
编辑:这些是我正在使用的 Excel 2007/2010 文件
edit2:如果我执行“从工作表中选择*”而不是“从工作表中选择*,其中某些内容”,我似乎实际上可以选择电子表格中的所有
行猜测当您实现 WHERE 子句时,结果行数上限为 65535
Here's what my connection string looks like..
m_conn = new OleDbConnection(String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=" + (char)34 + "Excel 12.0;HDR=YES" + (char)34, m_fileName));
When I do a select, I only get 65535 rows back but I know the excel spreadsheet has at least 100,000. How Do I read the rest of the rows. Note I have to use OLEDB, no 3rd party tools right now.
Thanks much!
edit: These are Excel 2007/2010 files I'm working with
edit2: Would seem I can actually select all the rows in the spreadsheet if I do a "Select * from worksheet" as opposed to "Select * from worksheet WHERE something"
I guess when you implement a WHERE clause, the resulting rows is capped at 65535
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据我的经验,Excel 工作表的行数限制为 65535 行(Excel 截至 2003 年,我不知道 2007 版本)。
编辑 #1
我的猜测是,OleDB 数据提供程序可能需要更新来纠正因 Excel 限制更改而导致的此问题。
As per my experience, an Excel worksheet is limited to 65535 lines (Excel up to 2003, I don't know about the 2007 version).
EDIT #1
My guess is that the OleDB data provider perhaps needs an update to correct this issue issued from the change of this Excel's limit.
如果您只想读取 Excel 文件,我建议尝试开源 Excel 数据阅读器。
If you only want to read an Excel file, I recommend trying the open-source Excel Data Reader.
您应该打开此类文件并在关闭兼容模式的情况下保存它们。您的查询将超过 64k。
You should open such files and save them with compatibility mode turned off. You will get more than 64k in your queries.