Monday, May 24, 2010

Can Visual C++ read from an excel file?

I am trying to find a programming language that will read from an excel file. Is there a simple way Visual C++ or C# can read from an excel file? If not, are there any languages in visual Studio .Net that will do this form me? I would like an example. Thanks

Can Visual C++ read from an excel file?
It depends on what you want to do: work with Excel itself and simply program a module or DDE interface; use Excel as a data source for a given application; program an application or different Office program to do things with Excel.





It sounds like what you want to do is use Excel as a datasource.





You can very easily fill an ADO.NET DataTable with information from an Excel spreadsheet, then manipulate the data in the DataTable:





using System.Data;


using System.Data.OleDb;





OleDbConnection con = new OleDbConnection( @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Book1.xls; Extended Properties=Excel 8.0");


OleDbDataAdapter da = new OleDbDataAdapter( "SELECT * FROM spreadsheet", con);


DataTable dt = new DataTable();


da.Fill(dt);





You may find this link helpful:





http://msdn.microsoft.com/library/defaul...


No comments:

Post a Comment