我无法打开.xlsx文件 [英] I cannot open .xlsx file
问题描述
我想打开一个xlsx文件,我已经尝试了下面的代码,但它也没有打开,也没有抛出任何错误。
任何人都可以投掷任何光在它
string path =C:\\examples\\file1.xlsx;
string connString = string.Format(Provider = Microsoft.ACE.OLEDB.12.0; Data Source =+ path +;扩展属性= \Excel 12.0 Xml; HDR = YES\;) ;
OleDbConnection cn = new OleDbConnection(connString);
cn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter(SELECT * FROM [Sheet1 $],cn);
DataTable dt = new DataTable();
adapter.Fill(dt);
您是否在64位Windows上运行?上次我检查了OLE驱动程序的Excel工作簿没有使用64位Windows。
SpreadsheetGear for .NET 将让您从.NET阅读Excel工作簿,并使用.NET 2.0+(包括64位Windows)。
免责声明:我拥有SpreadsheetGear LLC
I want to open an xlsx file, I have tried the below code,but neither does it open nor does it thrown any error.
Can anyone throw any light upon it
string path = "C:\\examples\\file1.xlsx";
string connString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\";");
OleDbConnection cn = new OleDbConnection(connString);
cn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", cn);
DataTable dt = new DataTable();
adapter.Fill(dt);
Are you running it on 64 bit Windows? Last time I checked the OLE drivers for Excel workbooks did not work with 64 bit Windows.
SpreadsheetGear for .NET will let you read Excel workbooks from .NET and works with .NET 2.0+ - including 64 bit Windows.
You can see live samples here and download the free trial here.
Disclaimer: I own SpreadsheetGear LLC
这篇关于我无法打开.xlsx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!