Results 1 to 4 of 4

Thread: [RESOLVED] Inserting data from VB into Excel.??? Need help!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Posts
    110

    Resolved [RESOLVED] Inserting data from VB into Excel.??? Need help!

    Hi!

    I'm trying to find an easy way to export data from my database using VB.
    I already managed to write some textbox values into excel, but since this takes a lot of time and is not practical in my program, I need to learn how to export masses at a time...

    So, I need to write 6 different values from the database table (shown in the picture in red) that are decided by 3 other values (shown in the picture in blue).

    I have a Form1 where I can choose the "ProjHenkID", "TyöNro" and "Pvm:" (shown in blue)...


    Started the code like:
    Code:
    Dim MyExcel As New Excel.Application
            MyExcel.Workbooks.Open("C:\Tuntilappu.xls")
            MyExcel.Visible = True
    but don't know how to call values from the database and insert them into specific cells in Excel...
    Attached Images Attached Images  

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Posts
    110

    Re: Inserting data from VB into Excel.??? Need help!

    Just to make the question more clear...


    - How can I insert specific data from my database into specific cells in my existing Excel -file?



    (I shoose the "ProjHenkID", "TyöNro" and "Pvm:" -values from my Form1 and by these informations the program should search the 6 different variables from the database and insert them into my Excel files specific cells....)





    The picture below shows how the data should be populated into the Excel file....
    Attached Images Attached Images  

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: Inserting data from VB into Excel.??? Need help!

    In the .NET CodeBank, I have a class that I use for exporting datatables and datareaders to Excel (search for threads started by me). It will not do exactly what you want, because it fills out data in order, whereas you want specific items to go to specific cells. However, it would be something that you could build from, as you would only be changing the cell indeces, perhaps.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Posts
    110

    Re: Inserting data from VB into Excel.??? Need help!

    Quote Originally Posted by Shaggy Hiker View Post
    In the .NET CodeBank, I have a class that I use for exporting datatables and datareaders to Excel (search for threads started by me). It will not do exactly what you want, because it fills out data in order, whereas you want specific items to go to specific cells. However, it would be something that you could build from, as you would only be changing the cell indeces, perhaps.
    Ok. Thanks! I found this one: http://www.vbforums.com/showthread.php?t=553246

    Will be looking through it and hopefully learning some new stuff on how to do things...

Tags for this Thread

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