Results 1 to 8 of 8

Thread: Using Excel To Create Reports

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2007
    Posts
    37

    Using Excel To Create Reports

    could you pls show me how to export to excel
    Last edited by Hack; Mar 14th, 2007 at 08:16 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Using Excel To Create Reports

    I've taken your post from an old, old thread in the database section and moved it into its own, new, thread.

    What platform will you be using, VB6 or VB.NET?

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2007
    Posts
    37

    Re: Using Excel To Create Reports

    Hi Hack sorry for reply late because i need to settle the Rent interface first before i go into printing invoice for customer . so what is the best way of doing it by excel or by access. with my rent interface there is a print invoice button when the user click on that button it will print the invoice to customer

    in the invoice have , customer name, address telphone , invoice number, Item that they rent and so on . i want it a simple way so i try out with excel but excel doesn't show the data in the excel sheet pls help. below are my code

    [vb] Code:
    1. Dim objexcel as object
    2. Set objexcel= createobject(“Excel.sheet”)
    3. objexcel.application.cell(3,9).value=text1.text ‘invoice number
    4.  
    5. objexcel.application.cell(3,12).value=text2.text ‘customer name
    6.  
    7. -
    8. -
    9. -
    10.  
    11. objexcel.application.visible=true
    Last edited by songoku; Mar 26th, 2007 at 03:08 AM.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Using Excel To Create Reports

    Your code isn't quite right.. see my Excel tutorial (link in my signature) for the correct methods.

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2007
    Posts
    37

    Re: Using Excel To Create Reports

    Hi Si _the_geek thanks i have try out it work. now i have another problem is where i need to print something like his
    Code:
    Movie id        Movie Name           Price
    
    SD1              Superman                    9
    MT1               Matrix                         9
    but what i get is something like this

    Code:
    Movie id                      Movie Name          P rice
    SD1                                MT1
    Superman                           Matrix     
    9                                         9

    pls help me below is my coding

    vb Code:
    1. Dim objexcel As Excel.Application
    2. Dim objsheet As Excel.Worksheet
    3. Dim objbook As Excel.Workbook
    4.  
    5.  
    6. Set objexcel = New Excel.Application
    7. Set objbook = objexcel.Workbooks.Add
    8. Set objsheet = objbook.Worksheets(1)
    9.  
    10. objexcel.Visible = True
    11. For i = 0 To titlecount - 1
    12. objsheet.Cells(1, i + 2).Value = List1.List(i)
    13.  
    14.  
    15. objsheet.Cells(1, 2, i + 1).Value = List2.List(i)
    16.  
    17.  
    18. objsheet.Cells(3 i + 1).Value = List3.List(i)
    19. Next
    Last edited by si_the_geek; Apr 6th, 2007 at 08:52 AM. Reason: added code tags to keep data format

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Using Excel To Create Reports

    It looks like you have got the .Cells method a bit confused.. you should be specifying two parameters, which are the Row and Column numbers.

    As the row number in this case should be specified based on the loop counter, I presume this is what you want:
    Code:
    objsheet.Cells(i + 2, 1).Value = List1.List(i)
    objsheet.Cells(i + 2, 2).Value = List2.List(i)
    objsheet.Cells(i + 2, 3).Value = List3.List(i)
    ..and I hope you have more code than you are showing - as you aren't releasing the object variables, etc.

  7. #7

    Thread Starter
    Member
    Join Date
    Feb 2007
    Posts
    37

    Re: Using Excel To Create Reports

    thanks si_the_geek i will try it out and let you know later


  8. #8

    Thread Starter
    Member
    Join Date
    Feb 2007
    Posts
    37

    Re: Using Excel To Create Reports

    Hi Si_thee_geek it work perfectly

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