ya mau berbagi lagi export dari Grid ke excel

tetap di refrence tambahkan
microsft Excel object library


'EXPORT KE EXCEL
'Start a new workbook in Excel
Dim oApp As New Excel.Application
Dim oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet

Set oBook = oApp.Workbooks.Add
Set oSheet = oBook.Worksheets(1)

'Add the field names in row 1
Dim i As Integer
Dim iNumCols As Integer
iNumCols = rsCari.Fields.Count
For i = 1 To Grid1.Cols - 1
oSheet.Cells(1, i).Value = Grid1.TextMatrix(0, i)
Next



'Add the data starting at cell A2
For i = 1 To Grid1.Rows - 1
    For B = 1 To Grid1.Cols - 1
        oSheet.Cells(i + 1, B).Value = Grid1.TextMatrix(i, B)
    Next B
Next i
'oSheet.Range("A2").CopyFromRecordset rsCari

'Format the header row as bold and autofit the columns
With oSheet.Range("a1").Resize(1, iNumCols)
.Font.Bold = True
.EntireColumn.AutoFit
End With

oApp.Visible = True
oApp.UserControl = True


       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.

[Non-text portions of this message have been removed]

Kirim email ke