bonjour tout le monde
voila j'ai un datagridview(DGV_edition) que je voudrais exporter vers un fichier excel,sauf que le nombre des lignes est tres important

voici ma fonction
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Private Sub bt_excel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_excel.Click
 
 
        Dim save As New SaveFileDialog
 
        Dim n, i, j, c, k As Integer
 
        Dim wapp As Excel.Application
        Dim wsheet As Excel.Worksheet
        Dim wbook As Excel.Workbook
 
 
        wapp = New Excel.Application
        wbook = wapp.Workbooks.Add()
        wsheet = wapp.Sheets(1)
 
        n = DGV_edition.RowCount
 
        c = DGV_edition.Columns.Count
        i = 0
 
        While i <= n - 1
            If i = 0 Then
                For k = 0 To c - 2
                    wsheet.Cells(1, k + 1).Value = DGV_edition.Columns(k).Name
                Next
            End If
 
            j = i + 1
            k = 0
            While k <= c - 2
                wsheet.Cells(j + 1, k + 1).Value = DGV_edition.Rows(j - 1).Cells(k).Value
                k = k + 1
            End While
            i = i + 1
        End While
 
        save.Title = "Sauver le fichier exporter sous ?"
        save.DefaultExt = "xls"
        save.ShowDialog()
 
        wsheet.SaveAs("" & save.FileName & "")
        wapp.Workbooks.Close()
    End Sub
elle marche tres bien ,mais tres lente quand je veux exporter plus de 2000 lignes

svp auriez vous une autre fonction a me proposer plus rapide ou bien des idees pour l'ameliorer

je vous remercie d'avance pouur votre aide