Tolong pilih kategori sesuai, jenis posting (diskusi atau bukan) dan sertakan tag/topik yang sesuai seperti komputer, java, php, mysql, dll. Promosi atau posting tidak pada tempatnya akan kami hapus!
- Bagi Anda yang ingin mendaftar, baca link berikut:
http://diskusiweb.com/discussion/50491/how-to-registrasi-diskusiweb-com-baca-ini-terlebih-dahulu
- Cara menyisipkan kode program supaya tampil rapi dan terformat dengan baik di diskusiweb.com: http://www.diskusiweb.com/discussion/50415/cara-menyisipkan-kode-program-di-diskusiweb-com
- Cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

buat report dengan MS.excel

tolong dong gimana cara bikin report dengan Ms Excel di vb?

Comments

  • pake microsoft object library aja yg ada di reference.....
  • Originally posted by finsa
    tolong dong gimana cara bikin report dengan Ms Excel di vb?

    Hi, Finsa
    Klo mo Working with Excel menggunakan VB, ini contohnya:
    'do declare these variables you need to add a reference
    'to the microsoft excel 'xx' object library.
    
    'you need two text boxes and two command buttons
    'on the form, an excel file in c:\book1.xls
    
    Dim xl As New Excel.Application
    Dim xlsheet As Excel.Worksheet
    Dim xlwbook As Excel.Workbook 
    
    Private Sub Command1_Click()
    'the benifit of placing numbers in (row, col) is that you
    'can loop through different directions if required. I could
    'have used column names like "A1" 'etc. 
    
        Text1.Text = xlsheet.Cells(2, 1) ' row 2 col 1
        Text2.Text = xlsheet.Cells(2, 2) ' row 2 col 2 
    
    'don't forget to do this or you'll not be able to open
    'book1.xls again, untill you restart you pc.
        xl.ActiveWorkbook.Close False, "c:\book1.xls"
        xl.Quit
    End Sub 
    
    Private Sub Command2_Click()
        xlsheet.Cells(2, 1) = Text1.Text
        xlsheet.Cells(2, 2) = Text2.Text
        xlwbook.Save 
    
    'don't forget to do this or you'll not be able to open
    'book1.xls again, untill you restart you pc.
        xl.ActiveWorkbook.Close False, "c:\book1.xls"
        xl.Quit
    End Sub 
    
    Private Sub Form_Load()
        Set xlwbook = xl.Workbooks.Open("c:\book1.xls")
        Set xlsheet = xlwbook.Sheets.Item(1)
    End Sub 
    
    Private Sub Form_Unload(Cancel As Integer)
        Set xlwbook = Nothing
        Set xl = Nothing
    End Sub
    

    trus klo mo Convert database ke Excel, gunakan syntax ini CopyFromRecordset (Excel.Range.CopyFromRecordset),
    Function CopyFromRecordset(Data As Unknown, [MaxRows], [MaxColumns]) As Long
    

    cexcelvt3.jpg
    By gyus at 2008-06-09


    Salam, lewat... :cool:
  • siiiiip dahhhh:cool:
  • mkasih bget udah ngbantuain
Sign In or Register to comment.