ACE oleDb 驱动程序无法处理巨大的 Excel 文件
ACE OLEDB 驱动程序对于较大的文件是否存在任何已知问题? 我使用下面的代码检索 400Mb xls 文件中的工作表,
public string[] GetWorkSheets()
{
var connectionString = "Provider=Microsoft.ACE.OleDb.12.0; data source=c:\filepath\filename.xls; Extended Properties=\"Excel 8.0;IMEX=1;HDR=YES;\"";
DataTable dataTable;
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
connection.Open();//Exception thrown here for large files
dataTable = connection.GetSchema("Tables");
}
int lenght = dataTable.Rows.Count;
string[] worksheets = new string[lenght];
for (int i = 0; i < lenght; i++)
{
worksheets[i] = dataTable.Rows[i]["TABLE_NAME"].ToString();
}
return worksheets;
}
我收到 OleDbException,其中包含消息系统资源超出。在到达此处之前,我不会循环调用此函数,也不会打开任何其他连接。此代码非常适合较小的文件。
我的系统有 4Gb RAM。在 Windows 7 64 位上运行。 Ace 驱动程序也是 64 位的。
知道可以做些什么来解决这个问题吗?
Does ACE OLEDB drivers have any known issues with larger files?
I am using the below code to retrieve the worksheets in a 400Mb xls file
public string[] GetWorkSheets()
{
var connectionString = "Provider=Microsoft.ACE.OleDb.12.0; data source=c:\filepath\filename.xls; Extended Properties=\"Excel 8.0;IMEX=1;HDR=YES;\"";
DataTable dataTable;
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
connection.Open();//Exception thrown here for large files
dataTable = connection.GetSchema("Tables");
}
int lenght = dataTable.Rows.Count;
string[] worksheets = new string[lenght];
for (int i = 0; i < lenght; i++)
{
worksheets[i] = dataTable.Rows[i]["TABLE_NAME"].ToString();
}
return worksheets;
}
I receive a OleDbException with the message System resource exceeded. I am not calling this function in loops, or opening any other connection before I reach here. This code works perfectly for smaller files.
My system has 4Gb RAM.Runs on Windows 7 64Bit. The Ace driver is also 64bit.
Any idea what can be done on fix this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您使用的是 ACE,所以我假设它是 32 位平台。赢2k3?
您是否尝试过使用 boot.ini 中的 /3GB 开关?
除非在 Boot.ini 文件中使用 /3GB 开关,否则进程和应用程序的虚拟地址空间仍限制为 2 GB。
http://www.microsoft.com/whdc/system/platform /server/pae/paemem.mspx
使用 /3GB,您可以获得额外的 1 GB,这可能会起到作用?
You are using ACE so i assume it is a 32bit platflorm. Win2k3?
Have you tried it with the /3GB switch in boot.ini?
The virtual address space of processes and applications is still limited to 2 GB unless the /3GB switch is used in the Boot.ini file.
http://www.microsoft.com/whdc/system/platform/server/pae/paemem.mspx
With /3GB you get one GB extra which might just do the trick?
阅读这篇文章
http://office.microsoft.com microsoft.com/en-us/excel-help/excel-specifications-and-limits-HP010073849.aspx
也许您的文件有超过 1,048,576 行 x 16,384 列?
read this article
http://office.microsoft.com/en-us/excel-help/excel-specifications-and-limits-HP010073849.aspx
maybe your file has more then 1,048,576 rows by 16,384 columns?