Read Excel 2010 64 Bit File On A 64 Bit Machine Using OleDB Provider In C#
Good afternoon!
In the forums where I am a contributor, here's a tip on how to read an excel 2010 64/32 bit file using C#. The Operating System of my machine is Windows 8 64 bit. So, here are the steps.
1. Download AccessDatabaseEngine_x64.exe
For 32 bit excel on windows 8 64 bit machines, download AccessDatabaseEngine.exe
2. Install it in my laptop.
3. Restart my laptop.
3. Change Active Config of Visual Studio Solution to Debug|Any CPU.
For 32 bit excel, choose Debug|X86 4. Clean and Rebuild The Solution.
Code:
Run my program.
Cheers!
In the forums where I am a contributor, here's a tip on how to read an excel 2010 64/32 bit file using C#. The Operating System of my machine is Windows 8 64 bit. So, here are the steps.
1. Download AccessDatabaseEngine_x64.exe
For 32 bit excel on windows 8 64 bit machines, download AccessDatabaseEngine.exe
2. Install it in my laptop.
3. Restart my laptop.
3. Change Active Config of Visual Studio Solution to Debug|Any CPU.
For 32 bit excel, choose Debug|X86 4. Clean and Rebuild The Solution.
Code:
private void Form1_Load(object sender, EventArgs e) { try { System.Data.OleDbOleDbConnection MyConnection; System.DataDataSet DtSet; System.Data.OleDbOleDbDataAdapter MyCommand; MyConnection = new System.Data.OleDbOleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='c:\\temp\\test.xlsx';Extended Properties=Excel 12.0;"); MyCommand = new System.Data.OleDbOleDbDataAdapter("select * from [Sheet1$]", MyConnection); //MyCommand.TableMappings.Add("Table", "TestTable"); DtSet = new System.DataDataSet(); MyCommand.Fill(DtSet); dataGridView1.DataSource = DtSet.Tables[0]; //load excel file to datagridview MyConnection.Close(); } catch (Exception ex) { } }
Cheers!
Comments
Post a Comment