Results 1 to 2 of 2

Thread: datasource to excel

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Location
    North east UK
    Posts
    129

    datasource to excel

    Hi All,

    i am trying to copy the data from a connection to a database directly to a new excel worksheet. Not having much luck but this is what i have so far:

    VB Code:
    1. da = New SqlClient.SqlDataAdapter("select * from myTable", sqlConn)
    2.             da.Fill(dsICheck, "CDetails")
    3.  
    4.             'Create a new workbook in Excel.
    5.             Dim xlApp As New Excel.Application
    6.             Dim xlBook As New Excel.Workbook
    7.             Dim xlSheet As New Excel.Worksheet
    8.  
    9.             xlApp = CType(CreateObject("Excel.Application"), Excel.Application)
    10.             xlBook = CType(xlApp.Workbooks.Add, Excel.Workbook)
    11.             xlSheet = CType(xlBook.Worksheets(1), Excel.Worksheet)
    12.  
    13.             xlSheet.Application.Visible = True
    14.  
    15. 'here is where i come unstuck!
    16. 'i need to copy the rows from dsICheck to test.xls
    17.  
    18.             xlSheet.SaveAs("C:\test.xls")

    Any help appreciated

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036
    Hi

    xlBook.Range("b4").Value = "Value"

    regards

    Jorge

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width