BELAJAR SENDIRI COMPUTER Headline Animator

Tampilkan postingan dengan label Export Data dari Flex Grid VB 6.0 Ke Excel. Tampilkan semua postingan
Tampilkan postingan dengan label Export Data dari Flex Grid VB 6.0 Ke Excel. Tampilkan semua postingan

Sabtu, 11 September 2010

Code Program Export Data Dari Flex Grid VB 6.0 Ke Excel

Private Sub Command3_Click()
Dim IROW As Integer
Dim ICOL As Integer
Dim OBJEXCL As Excel.Application
Dim objwk As Excel.Workbook
Dim objsht As Excel.Worksheet
Dim ihead As Integer
Dim vhead As Variant
Set OBJEXCL = New Excel.Application
OBJEXCL.Application.Visible = True
Set objwk = OBJEXCL.Workbooks.Add
Set objsht = objwk.Sheets(1)
vhead = Split(MSFlexGrid1.FormatString, "|")
For ihead = 1 To UBound(vhead)
If Len(Trim(vhead(ihead))) > 0 Then objsht.Cells(1, ihead) = vhead(ihead)
Next
For IROW = 1 To MSFlexGrid1.Rows - 1
For ICOL = 1 To MSFlexGrid1.Cols - 1
MSFlexGrid1.Row = IROW
MSFlexGrid1.Col = ICOL
objsht.Cells(IROW + 1, ICOL) = MSFlexGrid1.Text

Next ICOL
Next IROW
'objwk.SaveAs "c:\sheet1.xls"
objwk.Close
OBJEXCL.Quit
Set objsht = Nothing
Set objwk = Nothing
Set OBJEXCL = Nothing
End Sub
Private Sub form_load()
On Error Resume Next
With MSFlexGrid1
.Row = 125
.Cols = 9
For i = 0 To .Rows - 1
For j = 0 To .Cols - 1
.TextMatrix(i, j) = (i + 1) * (j + 1)
Next j
Next i
End With

End Sub

Cari Blog Ini

Pengikut