IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

Charger un fichier excel précis dans un endroit précis [Débutant]


Sujet :

VB.NET

  1. #1
    Membre habitué
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Juin 2005
    Messages
    608
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2005
    Messages : 608
    Points : 145
    Points
    145
    Par défaut Charger un fichier excel précis dans un endroit précis
    Bonjour
    Actuellement, mon appli charge dans un formulaire les données d'un fichier excel nommé monclasseur.xls toujours situé dans "mes documents", et ce sur click button (Private Sub btnLoadData_Click).
    A cet effet, j'utilise
    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
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
     
     'ouvre la feuille 1 de l'application mais la laisse invisible
                AppExcel = New OXL.Application
                xlWorkbook = AppExcel.Workbooks.Open(appPath & "\monClasseur.xls")
                xlWorkSheetOne = CType(xlWorkbook.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
                AppExcel.Visible = False
     
                'chargement des data en Textbox 
                Dim rng As OXL.Range = Nothing
     
                rng = CType(Me.xlWorkSheetOne.Cells(10, 7), Microsoft.Office.Interop.Excel.Range)
                Me.txtNOM.Text = CType(rng.Value, String)
     
                rng = CType(Me.xlWorkSheetOne.Cells(10, 8), Microsoft.Office.Interop.Excel.Range)
                Me.txtPRENOM.Text = CType(rng.Value, String)
     
                rng = CType(Me.xlWorkSheetOne.Cells(10, 9), Microsoft.Office.Interop.Excel.Range)
                Me.TxtNAISSANCE.Text = CType(rng.Value, String)
     
                rng = CType(Me.xlWorkSheetOne.Cells(16, 2), Microsoft.Office.Interop.Excel.Range)
                Me.S.Text = CType(rng.Value, String)
     
                rng = CType(Me.xlWorkSheetOne.Cells(16, 3), Microsoft.Office.Interop.Excel.Range)
                Me.C.Text = CType(rng.Value, String)
     
                rng = CType(Me.xlWorkSheetOne.Cells(16, 4), Microsoft.Office.Interop.Excel.Range)
                Me.AXE.Text = CType(rng.Value, String)
     
                rng = CType(Me.xlWorkSheetOne.Cells(16, 8), Microsoft.Office.Interop.Excel.Range)
                Me.SC.Text = CType(rng.Value, String)
     
                rng = CType(Me.xlWorkSheetOne.Cells(16, 9), Microsoft.Office.Interop.Excel.Range)
                Me.CC.Text = CType(rng.Value, String)
     
                rng = CType(Me.xlWorkSheetOne.Cells(16, 10), Microsoft.Office.Interop.Excel.Range)
                Me.AC.Text = CType(rng.Value, String)
    .
    .
    .
     
     MessageBox.Show("Data loaded in the form")
                CloseAppExcel()
    End Sub
    Private Sub CloseAppExcel()
            'procedure de fermeture du fichier excel
            If xlWorkSheetOne IsNot Nothing Then
                xlWorkSheetOne = Nothing
            End If
            If xlWorkSheetTwo IsNot Nothing Then
                xlWorkSheetTwo = Nothing
            End If
            If xlWorkbook IsNot Nothing Then
                xlWorkbook = Nothing
            End If
            If AppExcel IsNot Nothing Then
                AppExcel.Quit()
                AppExcel = Nothing
            End If
        End Sub
    Maintenant je voudrais ouvrir, toujours sur clic button, non pas toujours le meme nom de fichier toujours situé dans mes documents, mais le fichier que je veux, ou qu'il se trouve (tant que c'est un fichier .xls)

    J'ai pensé utiliser un Openfiledialog mais je n'arrive absolument pas a l'integrer correctement dans ma "Private Sub btnLoadData_Click"

  2. #2
    Membre expérimenté Avatar de hunteshiva
    Homme Profil pro
    Chef de projet en SSII
    Inscrit en
    Février 2010
    Messages
    1 069
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Chef de projet en SSII
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2010
    Messages : 1 069
    Points : 1 455
    Points
    1 455
    Par défaut
    Bonjour,

    Voici un bout de code qui devrait t'aider à l'integer

    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
            ' #####################################################
            ' ############# Déclaration des variables #############
            ' #####################################################
     
     
            ' Fichier Excel
            Dim CheminFicher As String
            Dim BoiteDialogue As New OpenFileDialog
     
            ' #####################################################
            ' ############ Recherche du fichier Excel #############
            ' #####################################################
     
            With BoiteDialogue
                ' Initialisation de la boite de dialogue
                .Title = "Selection d'un essai"
                .InitialDirectory = My.Application.Info.DirectoryPath ' répertoire de l'application
                .Filter = "Fichiers Excel |*.xls; *xlsx"
                ' vérification de la séléction
                If .ShowDialog() = System.Windows.Forms.DialogResult.OK Then
                    CheminFicher = .FileName
                Else
                    MsgBox("Aucun fichier Excel séléctionné")
                    Exit Sub ' Abandon de la routine
                End If
            End With

  3. #3
    Membre expérimenté Avatar de hunteshiva
    Homme Profil pro
    Chef de projet en SSII
    Inscrit en
    Février 2010
    Messages
    1 069
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Chef de projet en SSII
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2010
    Messages : 1 069
    Points : 1 455
    Points
    1 455
    Par défaut
    concernant ton code,
    il est pas mal j'aime bien quand tu commence avec "txtNOM", "txtPRENOM", ...

    Pourquoi abandonner cette syntaxte par la suite?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Me.S.Text
    Me.C.Text
    Me.AXE.Text
    On ne sais pas si c'est des labels, des textBox ou autre ....

    et le seconde point, c'est que tu devrais mettre des "Try" "Catch",
    si le fichier excel que tu charge n'est pas le bon, tu risque de planter ton appli.
    (cellules vides, ou autre pourraient générer une erreur)

  4. #4
    Membre habitué
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Juin 2005
    Messages
    608
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2005
    Messages : 608
    Points : 145
    Points
    145
    Par défaut
    Merci hunteshiva pour tes encouragements et tes conseils avises
    Je vais remedier a tout cela

  5. #5
    Membre expérimenté Avatar de hunteshiva
    Homme Profil pro
    Chef de projet en SSII
    Inscrit en
    Février 2010
    Messages
    1 069
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Chef de projet en SSII
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2010
    Messages : 1 069
    Points : 1 455
    Points
    1 455
    Par défaut
    De rien

    Pense a mettre

  6. #6
    Membre habitué
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Juin 2005
    Messages
    608
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2005
    Messages : 608
    Points : 145
    Points
    145
    Par défaut
    euh alors j'ai oublié un paramètre important qui doit me faire planter le "load" je pense
    dans mon classeur excel, j'ai 2 worksheet selon la veleur de mon etiquette et en l'occurence j'ai un peu oublié de la mentionner

    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
    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
    77
    78
    79
    80
    81
    82
     
     Private Sub btnLoadData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadData.Click
            txtDocteur2.Text = txtDocteur.Text
            If AppExcel IsNot Nothing Then
                MessageBox.Show("Excel Worksheet is closing please wait")
                If xlWorkSheetOne IsNot Nothing Then
                    xlWorkSheetOne = Nothing
                End If
                If xlWorkSheetTwo IsNot Nothing Then
                    xlWorkSheetTwo = Nothing
                End If
                If xlWorkbook IsNot Nothing Then
                    xlWorkbook = Nothing
                End If
                AppExcel.Quit()
                AppExcel = Nothing
            End If
     
            If Etiqoeiltraite.Text = "OD" Then
     
                'ouvre la feuille 1 de l'application mais la laisse invisible
                AppExcel = New OXL.Application
                xlWorkbook = AppExcel.Workbooks.Open(appPath & "\monClasseur.xls")
                xlWorkSheetOne = CType(xlWorkbook.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
                AppExcel.Visible = False
     
                'chargement des data en Textbox 
                Dim rng As OXL.Range = Nothing
     
                rng = CType(Me.xlWorkSheetOne.Cells(10, 7), Microsoft.Office.Interop.Excel.Range)
                Me.txtNOM.Text = CType(rng.Value, String)
     
                rng = CType(Me.xlWorkSheetOne.Cells(10, 8), Microsoft.Office.Interop.Excel.Range)
                Me.txtPRENOM.Text = CType(rng.Value, String)
    .
    .
    MessageBox.Show("Data loaded in the form")
                CloseAppExcel()
            End If
     
    If Etiqoeiltraite.Text = "OS" Then
     
                'ouvre l'onglet 2 de l'application
                AppExcel = New OXL.Application
                xlWorkbook = AppExcel.Workbooks.Open(appPath & "\monClasseur.xls")
                xlWorkSheetTwo = CType(xlWorkbook.Worksheets(2), Microsoft.Office.Interop.Excel.Worksheet)
                AppExcel.Visible = False
     
                'chargement des data en Textbox 
                Dim rng As OXL.Range = Nothing
     
                rng = CType(Me.xlWorkSheetTwo.Cells(10, 8), Microsoft.Office.Interop.Excel.Range)
                Me.txtPRENOM.Text = CType(rng.Value, String)
     
                rng = CType(Me.xlWorkSheetTwo.Cells(10, 7), Microsoft.Office.Interop.Excel.Range)
                Me.txtNOM.Text = CType(rng.Value, String)
     
                rng = CType(Me.xlWorkSheetTwo.Cells(10, 9), Microsoft.Office.Interop.Excel.Range)
                Me.TxtNAISSANCE.Text = CType(rng.Value, String)
    .
    .
     MessageBox.Show("Data loaded in the form")
                CloseAppExcel()
            End If
    End sub
     
    Private Sub CloseAppExcel()
            'procedure de fermeture du fichier excel
            If xlWorkSheetOne IsNot Nothing Then
                xlWorkSheetOne = Nothing
            End If
            If xlWorkSheetTwo IsNot Nothing Then
                xlWorkSheetTwo = Nothing
            End If
            If xlWorkbook IsNot Nothing Then
                xlWorkbook = Nothing
            End If
            If AppExcel IsNot Nothing Then
                AppExcel.Quit()
                AppExcel = Nothing
            End If
        End Sub
    la, je peux effectivement selectionner le fichier que je veux dans le rep que je veux mais au chargement ..... plantage total ....

  7. #7
    Membre habitué
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Juin 2005
    Messages
    608
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2005
    Messages : 608
    Points : 145
    Points
    145
    Par défaut
    j'y avais pensé mais je l'ai "déresolu" car je viens de constater un plantage objet du topic juste au dessus ....

  8. #8
    Membre expérimenté Avatar de hunteshiva
    Homme Profil pro
    Chef de projet en SSII
    Inscrit en
    Février 2010
    Messages
    1 069
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Chef de projet en SSII
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2010
    Messages : 1 069
    Points : 1 455
    Points
    1 455
    Par défaut
    Alors ton problème est résolu ou pas ??
    je te conseil de mettre la réponse a tes problèmes car même moi je ne comprend pas tout avec tes étiquettes.

    mais au chargement ..... plantage total ....
    Oui peut tu nous montrer la ligne et le message d'erreur retourné?

  9. #9
    Membre habitué
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Juin 2005
    Messages
    608
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2005
    Messages : 608
    Points : 145
    Points
    145
    Par défaut
    en fait je l'ai cru résolu et je me suis apercu que le chargement ne tenait pas compte du fait que il y avait des worksheet (1 et 2) dans le fichier excel.
    En fait pour faire simple, quand on parle de l'oeil gauche, j'ai une etiquette "OG" qui s'affiche dans le formulaire et si cette etiquette est affichée, on charge le worksheet2 du .xls
    Dans le cas de l'oeil droit, , etiquette OD, on charge le worksheet1
    Je pensais qu'en faisant :
    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
    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
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
     
     Private xlWorkbook As OXL.Workbook
        'feuille 1
        Private xlWorkSheetOne As OXL.Worksheet
        'feuille 2
        Private xlWorkSheetTwo As OXL.Worksheet
    .
    .
     
    Private Sub btnLoadData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadData.Click
            txtDocteur2.Text = txtDocteur.Text
            If AppExcel IsNot Nothing Then
                MessageBox.Show("Excel Worksheet is closing please wait")
                If xlWorkSheetOne IsNot Nothing Then
                    xlWorkSheetOne = Nothing
                End If
                If xlWorkSheetTwo IsNot Nothing Then
                    xlWorkSheetTwo = Nothing
                End If
                If xlWorkbook IsNot Nothing Then
                    xlWorkbook = Nothing
                End If
                AppExcel.Quit()
                AppExcel = Nothing
            End If
     With BoiteDialogue
                ' Initialisation de la boite de dialogue
                .Title = "Selection d'un essai"
                .InitialDirectory = My.Application.Info.DirectoryPath ' répertoire de l'application
                .Filter = "Fichiers Excel |*.xls; *xlsx"
                ' vérification de la séléction
                If .ShowDialog() = System.Windows.Forms.DialogResult.OK Then
                    CheminFicher = .FileName
                Else
                    MsgBox("Aucun fichier Excel séléctionné")
                    Exit Sub ' Abandon de la routine
                End If
            End With
     
            If Etiqoeiltraite.Text = "OD" Then
     
                'ouvre la feuille 1 de l'application mais la laisse invisible
                AppExcel = New OXL.Application
                xlWorkSheetOne = CType(xlWorkbook.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
                AppExcel.Visible = False
     
                'chargement des data en Textbox 
                Dim rng As OXL.Range = Nothing
     
                rng = CType(Me.xlWorkSheetOne.Cells(10, 7), Microsoft.Office.Interop.Excel.Range)
                Me.txtNOM.Text = CType(rng.Value, String)
     
                rng = CType(Me.xlWorkSheetOne.Cells(10, 8), Microsoft.Office.Interop.Excel.Range)
                Me.txtPRENOM.Text = CType(rng.Value, String)
    .
    .
    MessageBox.Show("Data loaded in the form")
                CloseAppExcel()
            End If
     
    If Etiqoeiltraite.Text = "OS" Then
     
                'ouvre l'onglet 2 de l'application
                AppExcel = New OXL.Application
                xlWorkSheetTwo = CType(xlWorkbook.Worksheets(2), Microsoft.Office.Interop.Excel.Worksheet)
                AppExcel.Visible = False
     
                'chargement des data en Textbox 
                Dim rng As OXL.Range = Nothing
     
                rng = CType(Me.xlWorkSheetTwo.Cells(10, 8), Microsoft.Office.Interop.Excel.Range)
                Me.txtPRENOM.Text = CType(rng.Value, String)
     
                rng = CType(Me.xlWorkSheetTwo.Cells(10, 7), Microsoft.Office.Interop.Excel.Range)
                Me.txtNOM.Text = CType(rng.Value, String)
     
                rng = CType(Me.xlWorkSheetTwo.Cells(10, 9), Microsoft.Office.Interop.Excel.Range)
                Me.TxtNAISSANCE.Text = CType(rng.Value, String)
    .
    .
     MessageBox.Show("Data loaded in the form")
                CloseAppExcel()
            End If
    End sub
     
    Private Sub CloseAppExcel()
            'procedure de fermeture du fichier excel
            If xlWorkSheetOne IsNot Nothing Then
                xlWorkSheetOne = Nothing
            End If
            If xlWorkSheetTwo IsNot Nothing Then
                xlWorkSheetTwo = Nothing
            End If
            If xlWorkbook IsNot Nothing Then
                xlWorkbook = Nothing
            End If
            If AppExcel IsNot Nothing Then
                AppExcel.Quit()
                AppExcel = Nothing
            End If
        End Sub
    cela fonctionnerait, mais en fait, si je peux choisir le document effectivement, je plante a la ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    xlWorkSheetOne = CType(xlWorkbook.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
    de type : l'exception nullreferenceException n'a pas ete gérée.

    Je pense a un souci entre les lignes bleues et l'initial directory de mon Openfiledialog. Je les ai mises en commentaires, peut etre dois je modifier mon initial directory ......

    Bref, j' y suis presque mais pas encore tout a fait ......

  10. #10
    Membre expérimenté Avatar de hunteshiva
    Homme Profil pro
    Chef de projet en SSII
    Inscrit en
    Février 2010
    Messages
    1 069
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Chef de projet en SSII
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2010
    Messages : 1 069
    Points : 1 455
    Points
    1 455
    Par défaut
    Je travaille sur le même type de fichier,
    je te laisse mon code et tu prend ce qui t’intéresse

    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
    45
    46
            ' #####################################################
            ' ############## Lecture du fichier Excel #############
            ' #####################################################
     
            Try
                ' Ouverture du fichier Excel
                Workbook = Excel_App.Workbooks.Open(CheminFicher)
     
                ' Recherche dans le feuillet Excel
                For Each ExcelWorkSheets As Microsoft.Office.Interop.Excel.Worksheet In Workbook.Worksheets
     
                    ' #####################################################
                    ' ################## Feuille RESULTAT #################
                    ' #####################################################
                    If (ExcelWorkSheets.Name = "RESULTAT") Then
     
                        ' etc.
     
                        'Nom de l'essai
                        Try
                            ' Recupération du nom de l'essai
                            Nom_Essai = ExcelWorkSheets.Range("F7").Value.ToString
                        Catch ex As Exception
                            Nom_Essai = Nothing
                            RESULTAT_Ok = False 'Erreur lors de la lecture
                        End Try
     
                        ' etc.
     
                    ' #####################################################
                    ' #################### Feuille DATA ###################
                    ' #####################################################
                    ElseIf (ExcelWorkSheets.Name = "DATA") Then
     
     
                        ' etc.
     
                    End If
     
                Next
     
            Catch ex As Exception
                MsgBox(ex.ToString, MsgBoxStyle.Critical, "Erreur lors de la lecture du fichier Excel")
                Exit Sub ' Abandon de la routine
     
            End Try
    Il est simplifié, tu n'a pas toutes les gestion d'erreurs. mais ça devrais t'aider à avancer

  11. #11
    Membre habitué
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Juin 2005
    Messages
    608
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2005
    Messages : 608
    Points : 145
    Points
    145
    Par défaut
    j'ai essaye de modifier
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    xlWorkbook = AppExcel.Workbooks.Open(appPath & "\monClasseur.xls")
    en
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    xlWorkbook = AppExcel.Workbooks.Open(.FileName & "\*.xls")
    et essaye d'ouvrir un excel appelé paul.xls.

    Resultat :
    'C:\Users\secretariat.CDLV\Documents\fiches patients\29022012\paul.xls\*.xls' introuvable. Vérifiez l'orthographe du nom du classeur et la validité de l'emplacement.
    j'ai ensuite essaye
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    xlWorkbook = AppExcel.Workbooks.Open(.FileName)
    la, je n'ai pas d'erreur, j'ai le message data loaded in the form ..... mais rien dans le form

    je suis a cours d'idées .............

    J'essaye avec ton code hunteshiva mais je suis un peu perdu entre mon code et le tien

  12. #12
    Membre éprouvé

    Homme Profil pro
    Inscrit en
    Mars 2012
    Messages
    691
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Israël

    Informations forums :
    Inscription : Mars 2012
    Messages : 691
    Points : 929
    Points
    929
    Par défaut
    xlWorkbook = AppExcel.Workbooks.Open(.FileName & "\*.xls")
    plutot


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    xlWorkbook = AppExcel.Workbooks.Open (CheminFicher )
    puisque le fichier que tu ouvres et forcément avec une extension xls

  13. #13
    Membre expérimenté Avatar de hunteshiva
    Homme Profil pro
    Chef de projet en SSII
    Inscrit en
    Février 2010
    Messages
    1 069
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Chef de projet en SSII
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2010
    Messages : 1 069
    Points : 1 455
    Points
    1 455
    Par défaut
    la, je n'ai pas d'erreur, j'ai le message data loaded in the form ..... mais rien dans le form
    Il faut que regarde pourquoi ,
    met des points d’arrêt un peu partout et regarde si ça ne vient pas de la lecture des cellules Excel.

    Comment fait tu la lecture de tes cellules?

  14. #14
    Membre habitué
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Juin 2005
    Messages
    608
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2005
    Messages : 608
    Points : 145
    Points
    145
    Par défaut
    eh ben bien joué une fois de plus shayW, tout fonctionne impeccablement maintenant

    gros merci a vous deux pour l'aide et la disponibilité

  15. #15
    Membre habitué
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Juin 2005
    Messages
    608
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2005
    Messages : 608
    Points : 145
    Points
    145
    Par défaut
    Citation Envoyé par hunteshiva Voir le message
    Il faut que regarde pourquoi ,
    met des points d’arrêt un peu partout et regarde si ça ne vient pas de la lecture des cellules Excel.

    Comment fait tu la lecture de tes cellules?
    normal en fait et j'ai honte de la dire ........ le worksheet etait vide de données

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Débutant] Charger un fichier Excel dans une dataGrid
    Par shaun_the_sheep dans le forum Windows Forms
    Réponses: 2
    Dernier message: 18/07/2012, 08h15
  2. Réponses: 1
    Dernier message: 18/08/2011, 18h03
  3. Ecrire à un endroit précis dans un fichier txt
    Par fraid49 dans le forum Général Python
    Réponses: 2
    Dernier message: 02/10/2008, 09h53
  4. Ecrire à un endroit précis dans un fichier texte
    Par zemeilleurofgreg dans le forum Delphi
    Réponses: 4
    Dernier message: 26/06/2006, 21h51
  5. [C#] Lecture dans un endroit précis d'un fichier ...
    Par maitrebn dans le forum Windows Forms
    Réponses: 3
    Dernier message: 15/10/2004, 13h36

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo