Bonjour,

je voudrai savoir comment exporter un Dataset entier dans un fichier Excel en ASCX.VB.
Actuellement j'y arrive, mais je traite cellule par cellule, ligne par ligne... c'est très long.
Donc je souhaiterai copier mon Dataset entier directement dans le fichier.


voici mon code:
Code vb.net : 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
        Dim myds As DataSet = csdo.clstdo.PstSelect(Session("NumDem"), Session("Etat"), Session("Sec"), Session("Out"), Session("Typ"), Session("Clas"), Session("Section"), Session("Poste"), Session("Demandeur"), Session("Technicien"), Session("Operateur"), Session("SouTraEtd"), Session("SouTraRea"), Session("CodPro"), Session("Piece"), Session("DateAppDu"), Session("DateAppAu"), Session("DateCreDu"), Session("DateCreAu"), "33", Session("vtriDEM"), Session("otriDEM"))
 
        Try
            'selection de la feuille "PDCA"
            oshe = CType(oboo.Worksheets("export"), Excel.Worksheet)
        Catch ex As Exception
            'fermeture des objets excel
            fermExc(oshe, oboo, oApp)
            Exit Sub
        End Try
 
        oshe.Cells.Clear()
 
        oshe.Cells(1, 1).value = myds
 
        'En-tête de ligne
        oshe.Cells(1, 1).value = "Num de demande"
        oshe.Cells(1, 2).value = "Etat"
        oshe.Cells(1, 3).value = "Num Outillage"
        oshe.Cells(1, 4).value = "Qte"
        oshe.Cells(1, 5).value = "Code projet"
        oshe.Cells(1, 6).value = "Num note"
        oshe.Cells(1, 7).value = "Section"
        oshe.Cells(1, 8).value = "Poste"
        oshe.Cells(1, 9).value = "Date d'application"
        oshe.Cells(1, 10).value = "PA Demandeur"
        oshe.Cells(1, 11).value = "Nom Demandeur"
        oshe.Cells(1, 12).value = "Type"
        oshe.Cells(1, 13).value = "Classification"
        oshe.Cells(1, 14).value = "Technicien"
        oshe.Cells(1, 15).value = "Sous-traitant / Opérateur: étude"
        oshe.Cells(1, 16).value = "Date prévisionnelle: étude"
        oshe.Cells(1, 17).value = "Date réelle: étude"
        oshe.Cells(1, 18).value = "Num DA: étude"
        oshe.Cells(1, 19).value = "Prix: étude"
        oshe.Cells(1, 20).value = "Sous-traitant / Opérateur: réalisation"
        oshe.Cells(1, 21).value = "Date prévisionnelle: réalisation"
        oshe.Cells(1, 22).value = "Date réelle: réalisation"
        oshe.Cells(1, 23).value = "Num DA: réalisation"
        oshe.Cells(1, 24).value = "Prix / Nb Heures: réalisation"
        oshe.Cells(1, 25).value = "Date création demande"
        oshe.Cells(1, 26).value = "Validation demande"
 
        Dim typ As String = String.Empty
        'En-tête de ligne (semestre)
        Dim lig As Integer = 0
        For lig = 0 To myds.Tables(0).Rows.Count - 1
            'For col As Integer = 0 To myds.Tables(0).Columns.Count - 1
            oshe.Cells(lig + 2, 1).value = myds.Tables(0).Rows(lig).Item("DemN").ToString
            oshe.Cells(lig + 2, 2).value = myds.Tables(0).Rows(lig).Item("NomEta")
            oshe.Cells(lig + 2, 3).value = myds.Tables(0).Rows(lig).Item("NumOut")
            oshe.Cells(lig + 2, 4).value = myds.Tables(0).Rows(lig).Item("Qte")
            oshe.Cells(lig + 2, 5).value = myds.Tables(0).Rows(lig).Item("CodPro")
            oshe.Cells(lig + 2, 6).value = myds.Tables(0).Rows(lig).Item("NumNot")
            oshe.Cells(lig + 2, 7).value = myds.Tables(0).Rows(lig).Item("Sec")
            oshe.Cells(lig + 2, 8).value = myds.Tables(0).Rows(lig).Item("Post")
            oshe.Cells(lig + 2, 9).value = myds.Tables(0).Rows(lig).Item("DatApp")
            oshe.Cells(lig + 2, 10).value = myds.Tables(0).Rows(lig).Item("Dem")
            oshe.Cells(lig + 2, 10).value = myds.Tables(0).Rows(lig).Item("NomDem")
            oshe.Cells(lig + 2, 11).value = myds.Tables(0).Rows(lig).Item("TypCreMod")
            oshe.Cells(lig + 2, 12).value = myds.Tables(0).Rows(lig).Item("NomSpe")
            oshe.Cells(lig + 2, 13).value = myds.Tables(0).Rows(lig).Item("nomTec")
            oshe.Cells(lig + 2, 14).value = myds.Tables(0).Rows(lig).Item("SouTraEtd")
            oshe.Cells(lig + 2, 15).value = myds.Tables(0).Rows(lig).Item("DatEtdPre")
            oshe.Cells(lig + 2, 16).value = myds.Tables(0).Rows(lig).Item("DatEtdRee")
            oshe.Cells(lig + 2, 17).value = myds.Tables(0).Rows(lig).Item("NumDaEtd")
            oshe.Cells(lig + 2, 18).value = myds.Tables(0).Rows(lig).Item("PrixEtd")
            oshe.Cells(lig + 2, 19).value = myds.Tables(0).Rows(lig).Item("SouTraRea")
            oshe.Cells(lig + 2, 20).value = myds.Tables(0).Rows(lig).Item("DatReaPre")
            oshe.Cells(lig + 2, 21).value = myds.Tables(0).Rows(lig).Item("DatReaRee")
            oshe.Cells(lig + 2, 22).value = myds.Tables(0).Rows(lig).Item("PrixRea")
            oshe.Cells(lig + 2, 23).value = myds.Tables(0).Rows(lig).Item("NumDaRea")
            oshe.Cells(lig + 2, 24).value = myds.Tables(0).Rows(lig).Item("PrixRea")
            oshe.Cells(lig + 2, 25).value = myds.Tables(0).Rows(lig).Item("DatCre")
            oshe.Cells(lig + 2, 26).value = myds.Tables(0).Rows(lig).Item("DatSold")
        Next

Merci de votre aide.