Retrieve data from a closed workbook in VB.Net

  • Recently I played around with retrieving data from a closed workbook in VB.Net and decided to share it with You here at OzGrid.

    What we need:
    * MS WIndows 2000 or above
    * MS Excel 2000 or above
    * MDAC 2.5 or above
    * MS Visual Basic.Net 2003

    The examples demonstrate several valid way to connect and retrieve data from a closed workbook.

    However the "real" ADO.Net in the last example shows the power and intelligent MS has provided ADO.Net with.

    #1 Classic approach using a reference to the ADO-library, i e early binding:

    #2 Semi-classic approach
    With a reference to ADO and the use of Adapter & Dataset (similar to disconnected recordset in classic ADO).

    We need also to import the library Data:

    #3 The ADO.Net approach

    I really like the way we can work with ADO.Net :)