How do I read an Excel file in .Net Compact Framework 2.0?

Hello,

I'm developing a windows mobile 5.0 application that reads an excel file as a datatable. To do this in normal .net framework 2.0, I use the below code and there is no problem. What my problem is when using it in .net compact framework, there is no DbProviderFactory class ("System.Data.Common.DbProviderFactory" library does not exist).

Can anyone please help me reading this excel file in windows mobile please?

Thank you,
Afsar.
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\input.xls;Extended Properties=""Excel 8.0;HDR=NO;IMEX=1""";
DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb");
DbDataAdapter adapter = factory.CreateDataAdapter();
DbCommand selectCommand = factory.CreateCommand();
selectCommand.CommandText = "SELECT * FROM [Sheet1$]";
DbConnection connection = factory.CreateConnection();
connection.ConnectionString = connectionString;
selectCommand.Connection = connection;
adapter.SelectCommand = selectCommand;
DataSet table = new DataSet();
adapter.Fill(table);
DataTable dtResult = table.Tables[0];

Open in new window

aemekliAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DanielSVCommented:
According to the MSDN forum you'll have to use the Codeplex Excel Data Reader, as no solution is included in the .NET compact framework.

Link to MSDN forum thread: http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/eadf8e6b-c2ae-4b35-8b1d-ebead03bffb7
Link to data reader: http://exceldatareader.codeplex.com/Wikipage
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DanielSVCommented:
BTW: It's LGPLd, meaning you can link against it without having to make your code open source, so I believe it could be an acceptable solution for you.
0
Meir RivkinFull stack Software EngineerCommented:
there is no data provider or driver support for Excel (or Pocket Excel) running under the Compact Framework.
u can any 3rd party softwares which does that, like the following:

http://www.codeplex.com/ExcelDataReader
http://www.tmssoftware.com/site/flexcelnet.asp

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Smartphone Programming

From novice to tech pro — start learning today.