Bonjour à toutes et à tous,

Je souhaite intégrer une partie de code à mon programme afin de récupérer des données et les écrire dans un fichier Calc.
J'arrive à insérer les données dans mon fichier Calc mais mon souci est que chaque fois que j'écris dedans mon fichier est écrasé.
Du coup je ne peux pas modifier mon fichier Calc manuellement puisque chaque modification sera écrasé une fois que mon programme tournera.
Y a t'il un moyen de simplement écrire dans le fichier sans pour autant qu'il m'en créé un nouveau à chaque fois ?

Voici mon code avec la partie concernée en violet:

Merci d'avance pour votre aide

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
        
Try

            Dim maListeDeResultat As List(Of ResultatEnquete) = New List(Of ResultatEnquete)
            Dim enteteTableau As Boolean = True
            Dim compteur As Integer = 0

            'Lecture du fichier texte avec les chemin vers les tableaux
            Dim sw As String = Application.StartupPath() & "\CheminEnquetes.TXT"
            Dim linebis As List(Of String) = File.ReadLines(sw).ToList()
            Dim LienLCA As String
            LienLCA = linebis(3)

            'Déclaration des variables pour le fichier de suivi
            Dim oSM As Object = CreateObject("com.sun.star.ServiceManager")
            Dim oMM As Object = oSM.createInstance("com.sun.star.frame.Desktop")
            Dim arg(0) As Object
            arg(0) = oSM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
            arg(0).name = "Hidden"
            arg(0).Value = True
            Dim objCalc As Object = oMM.LoadComponentFromUrl("private:factory/scalc", "_blank", 0, arg)
            Dim objSheet As Object = objCalc.Sheets.getByIndex(0)

            Dim line As String
            Dim readFileLC As System.IO.TextReader = New StreamReader("" & LienLCA & "")

            While True
                line = readFileLC.ReadLine()
                If line Is Nothing Then
                    Exit While
                Else
                    'je splite les lignes si elles contiennent qqch
                    If line.Contains("|") Then
                        'je suis dans le tableau
                        compteur = compteur + 1
                        If compteur > 2 Then
                            Dim maLigne() As String = line.Split("|")
                            Dim monResLC As ResultatEnquete = New ResultatEnquete
                            monResLC.numeroEnqueteur = maLigne.GetValue(0)
                            monResLC.nomEnqueteur = maLigne.GetValue(1)
                            monResLC.TOT = maLigne.GetValue(2).ToString().Replace(".", ",")
                            monResLC.FAIT = maLigne.GetValue(3).ToString().Replace(".", ",")
                            monResLC.FAIT_POURCENT = maLigne.GetValue(4).ToString().Replace(".", ",")
                            monResLC.ERV = maLigne.GetValue(6).ToString().Replace(".", ",")
                            monResLC.IAJ = maLigne.GetValue(10).ToString().Replace(".", ",")
                            monResLC.REF = maLigne.GetValue(8).ToString().Replace(".", ",")
                            maListeDeResultat.Add(monResLC)

                            Dim oCell, oCell2, oCell3, oCell4 As Object
                            Dim VarDate As String
                            oCell = objSheet.getCellByPosition(1, compteur)
                            oCell.String = monResLC.FAIT
                            oCell2 = objSheet.getCellByPosition(2, compteur)
                            oCell2.String = monResLC.IAJ
                            oCell3 = objSheet.getCellByPosition(3, compteur)
                            oCell3.String = monResLC.REF
                            VarDate = DateTime.Now.Date
                            oCell4 = objSheet.getCellByPosition(0, 0)
                            oCell4.String = VarDate
                            objCalc.storetoURL("file:///C:/Users/XXXXX/Documents/Visual Studio 2013/Projects/Programme XXXX/Programme XXXX/bin/Debug/LCsuivi.ods", arg)
                        End If
                    End If
                End If
            End While
            readFileLC.Close()
            readFileLC = Nothing
            For Each resLC As ResultatEnquete In maListeDeResultat
                If resLC.nomEnqueteur.StartsWith(nomEnqueteur) Then
                    txtFaitPourcentLC.Text = resLC.FAIT_POURCENT
                    TxtTotLC.Text = resLC.TOT
                    TxtRealLC.Text = resLC.FAIT
                    TxtERVLC.Text = resLC.ERV
                End If
            Next
        Catch ex As Exception
            MsgBox(ex.ToString())
            Dim writeFile As System.IO.TextWriter = New StreamWriter("log.txt", True)
            writeFile.WriteLine("==================================================")
            writeFile.WriteLine(ex.ToString())
            writeFile.WriteLine("==================================================")
            writeFile.Flush()
            writeFile.Close()
            writeFile = Nothing
End Try