Excel-.NEt

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mathon

    #1

    Excel-.NEt

    Hello,

    I want to develop a little application, which extracts some values of an
    excel sheet and displays this values with a rectangle or a circle in a form.
    Are there any example how to implement such things?

    regards

    mathon
  • mathon

    #2
    RE: Excel-.NEt


    Is it not possible to extract values from an excel sheet to display for
    example in a DataGrid?? :(

    regards

    mathonhon

    Comment

    • smith

      #3
      Re: Excel-.NEt

      Excel is an ISAM just like dBase and Jet (Acceess). You can get at the data
      using Excel automation or, if you don;'t have the full Excel installed but
      have the Jet ISAM drivers on your user machine then you can open the sheets
      just like opening a Jet file by using the OLEDB provider. There are some
      limitations but getting the data for grid display (or INSERTs or UPDATES) is
      pretty straight forward using Jet-SQL syntax and the special bracket syntax
      as shown below for the Excel objects

      The following shows very general proof of concept code, this opens the
      connection and confirms that it is reading the data. Just use regular
      ado.net to iterate.

      The HDR=Yes in the connection string tells the provider that the first row
      of the sheet has values that are used as "Column Names", if your sheet
      doesn't have that then don't say Yes :)

      Imports System.Data.Ole db
      ......

      Dim cn As New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;" & _
      "Data Source=C:\mytes ts\book1.xls;" & _
      "Extended Properties=""Ex cel 8.0;HDR=Yes""")

      Dim ds As New DataSet
      Dim da As New OleDbDataAdapte r("Select * from [Sheet1$]", cn)
      cn.Open()
      Try
      da.Fill(ds)
      MsgBox(ds.Table s.Count)
      MsgBox(ds.Table s(0).Rows.Count )

      grid1.DataSourc e = ds.Tables(0)

      Catch ex As Exception
      MsgBox(ex.ToStr ing)
      End Try





      Hope that helps.

      Robert Smith
      Kirkland, WA




      "mathon" <mathon@discuss ions.microsoft. com> wrote in message
      news:0D7520A5-2365-4AFB-B6DA-C675250B8FCF@mi crosoft.com...[color=blue]
      >
      > Is it not possible to extract values from an excel sheet to display for
      > example in a DataGrid?? :(
      >
      > regards
      >
      > mathonhon[/color]


      Comment

      Working...