I cannot open .xlsx file in c#
Posted
by cmrhema
on Stack Overflow
See other posts from Stack Overflow
or by cmrhema
Published on 2010-04-11T15:40:32Z
Indexed on
2010/04/11
15:43 UTC
Read the original article
Hit count: 1175
c#
Hi, 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
Thanks Hema
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);
© Stack Overflow or respective owner