IO
With DataGridView1
.Columns.Clear()
.Columns.Add("No", "No")
.Columns.Add("NIK", "NIK")
.Columns.Add("Nama", "Nama")
.Columns.Add("Alamat", "Alamat")
.Columns.Add("Telp", "Telp")
End With
End Sub
End Sub
With DGV
.AllowUserToAddRows = False
.Name = "Student"
.Visible = False
.Columns.Clear()
.Columns.Add("No", "No")
.Columns.Add("NIK", "NIK")
.Columns.Add("Nama", "Nama")
.Columns.Add("Alamat", "Alamat")
.Columns.Add("Telp", "Telp")
End With
With DataGridView1
If .Rows.Count > 0 Then
For i As Integer = 0 To .Rows.Count - 1
Application.DoEvents()
DGV.Rows.Add(IIf(i = 0, 1, i + 1), .Rows(i).Cells("NIK").Value,
_
.Rows(i).Cells("Nama").Value,
.Rows(i).Cells("Alamat").Value, _
.Rows(i).Cells("Telp").Value)
Next
End If
End With
FlNm = "E:\Student " & Now.Day & "-" & Now.Month & "-" & Now.Year & ".xls"
'FlNm = Application.StartupPath & "\Student " _
' & Now.Day & "-" & Now.Month & "-" & Now.Year & ".xls"
If File.Exists(FlNm) Then File.Delete(FlNm)
ExportToExcel(DGV)
DGV.Dispose()
DGV = Nothing
Process.Start("E:\Student " & Now.Day & "-" & Now.Month & "-" & Now.Year &
".xls")
BtnExport.Text = "Export"
BtnExport.Enabled = True
End Sub
End Class