Bonjour à tous,
Voilà mon soucis:
J'ai réussi à coder une application capable d'ouvrir un fichier Excel, récupérer 2 colonnes, puis créer et écrire ces 2 colonnes séparées d'un ";" dans un fichier texte. J'aimerai maintenant, de la même manière, pouvoir faire tourner ce programme pour TOUS les fichiers d'un même dossier. Merci d'avance pour l'aide précieuse que vous pourriez m'apporter sur le sujet.
Voici mon code actuel:
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 Imports System.IO Imports Microsoft.Office.Interop Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles BT_CONVERSION.Click Dim xlApp As New Excel.Application Dim xlWb As Excel.Workbook Dim xlSh As Excel.Worksheet Dim colonne_outil(Reglages.TB_OUTIL2.Text) As String Dim colonne_cotation(Reglages.TB_OUTIL2.Text) As String xlWb = xlApp.Workbooks.Open(Reglages.TB_EXCEL.Text) xlSh = xlWb.Worksheets(1) Dim sw As New StreamWriter(Reglages.TB_TEXTE.Text) For i As Integer = 0 To colonne_outil.Length - 1 colonne_outil(i) = xlSh.Cells(i + Reglages.TB_DEBUT.Text, Reglages.TB_OUTIL.Text).Value 'Format du type (Ligne, Colonne) colonne_cotation(i) = xlSh.Cells(i + Reglages.TB_DEBUT.Text, Reglages.TB_COTATION.Text).Value If Not IsNumeric(colonne_cotation(i)) Then i = i + 1 If colonne_outil(i) Is Nothing Or Not IsNumeric(colonne_outil(i)) Then i = i + 1 Else sw.WriteLine(colonne_outil(i) & ";" & colonne_cotation(i)) Next sw.Close() End Sub Private Sub BT_REGLAGES_Click(sender As Object, e As EventArgs) Handles BT_REGLAGES.Click Reglages.Show() End Sub End Class
Partager