Archive for the ‘VisualBasic’ Category

Microsoft Excel LogoSuppose you have an Excel binary file (or in another ms format) and suppose you have to extract some data from it programmatically…

Suppose you don’t want to send commands to the installed Office Excel with OLE automation or similar technologies.

Suppose you want to query that file as a relational DB.
Well, here is the solution…

You can interface your code with the Excel file with ADO.NET, here is the example:


Dim cnn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Test.xls;Extended Properties=""Excel 8.0;HDR=YES;""")
Dim da As New OleDb.OleDbDataAdapter("Select * from [Sheet1$]", cnn)
Dim ds As New DataSet("TestExcel")

Simply not?

Read Full Post »