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
| ' Gambas module file
PUBLIC FUNCTION Sauvegarde_CSV(GV AS GridView) AS BOOLEAN DIM Fichier AS File DIM i AS INTEGER DIM j AS INTEGER DIM Chemin AS STRING Dialog.Filter = ["*.csv", "CSV Files"] IF Dialog.SaveFile() THEN RETURN Chemin = Dialog.Path TRY Fichier = OPEN Chemin FOR CREATE IF ERROR THEN Message("Impossible de créer le fichier!" "Ok") RETURN FALSE END IF FOR i = 0 TO GV.Columns.Count - 1 WRITE #Fichier, Str(GV.Columns[i].Title) WRITE #Fichier, Str(";") NEXT WRITE #Fichier, Str(gb.CrLf) FOR j = 0 TO GV.Rows.Count - 1 FOR i = 0 TO GV.Columns.Count - 1 IF GV[j, i].Text = "" THEN WRITE #Fichier, Str("0") ELSE WRITE #Fichier, Str(Replace$(GV[j, i].Text, ",", ".")) ENDIF WRITE #Fichier, Str(";") NEXT WRITE #Fichier, Str(gb.CrLf) NEXT CLOSE Fichier RETURN TRUE END
|