PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WEBDEV 2025 → upload fichier csv
upload fichier csv
Débuté par Laurent HERMANN, 27 jan. 2026 17:39 - Aucune réponse
Membre enregistré
362 messages
Posté le 27 janvier 2026 - 17:39
bonjour,

je recupére un projet windev avec ce code qui génére et sauve un fichier text.
soit sDossier = INILit("Chemins","Identification","",gsParams)
SI sDossier <> "" _et_ pas fRepExiste(sDossier) ALORS sDossier = ""

soit sDestination = fRepSélecteur(sDossier, "Sélectionnez un dossier")
SI sDestination = "" ALORS RETOUR

soit bOK = Vrai

Sablier()

TableTrie(TABLE_1,"COL_Numéro")

INIEcrit("Chemins","Identification",sDestination,gsParams)

taBadges est un tableau associatif d'entiers
pour TOUT Badges
taBadges[Badges.Numero] = Badges.IDPropriete
FIN

taPros est un tableau associatif de chaînes
pour TOUT Proprietes
taPros[Proprietes.ID] = Remplace(Proprietes.Num,["\","/"],"-")
FIN

taContainers est un tableau associatif de chaînes
pour TOUT Containers
SI Containers.Actif ALORS taContainers[Containers.IDPro] += ["|"] + taPros[Containers.IDPro] + ["-"] + Containers.Nom
FIN

taSupp, taRes, taAjouter sont des tableaux associatifs de chaînes
sSDK est une chaîne

// Préparation des lignes supplémentaires
pour toute ligne ni de TABLE_1
SI COL_EstSyndic _et_ NoEsp(COL_Propriété) = "" ALORS taSupp[COL_Syndic] += [RC] + InfosLigne(ni)
FIN

pour toute ligne nI de TABLE_1

SI COL_EstSyndic _et_ COL_Syndic = "SDK" ALORS sSDK += [RC] + InfosLigne(nI)

SI NoEsp(COL_Utilisateur) <> "" ALORS
pour toute chaîne sProCont de taContainers[taBadges[COL_Numéro]SEPAREE PARar "|"
SI taAjouter[sProCont] = "" ALORS
taAjouter[sProCont] = taSupp[COL_Syndic]
FIN
taRes[sProCont] += [RC] + InfosLigne(nI)
FIN
FIN

FIN

pour TOUT sContenu, sClé de taRes
SI PAS fSauveTexte(sDestination + ["\"] + "Identification-" + sClé + ".txt",sSDK + [RC] + sContenu + [RC] + taAjouter[sClé]) ALORS
SI EnModeTest() ALORS Info(ErreurInfo(errComplet))
bOK = Faux
FIN
FIN

SI bOK ALORS
Info("Les fichiers ont bien été créés")
SINON
Info("Erreur lors de la création des fichiers")
FIN

PROCEDURE INTERNE DateOK(dDate)
SI dDate <> "" _et_ DateValide(dDate) ALORS
RENVOYER DateVersChaîne(dDate,"AAAA-MM-JJ")
SINON
RENVOYER "2019-01-01"
FIN
FIN

PROCEDURE INTERNE LaFin(dDate)
SI dDate <> "" _et_ DateValide(dDate) ALORS
RENVOYER DateVersChaîne(dDate,"AAAA-MM-JJ")
SINON
RENVOYER "2999-12-31"
FIN
FIN

PROCEDURE INTERNE Actif(dDate)
SI PAS DateValide(dDate) _ou_ dDate > DateSys() ALORS RENVOYER "1"
RENVOYER "0"
FIN

PROCEDURE INTERNE NoEsp(sTxt)
RENVOYER SansEspace(sTxt,sscTout)
FIN

PROCEDURE INTERNE InfosLigne(nLigne)
RENVOYER SansEspace(COL_Numéro[nLigne],sscTout) + TAB + COL_Code[nLigne] + TAB + "0" + TAB + "0" + TAB + DateOK(COL_Du[nLigne]) + TAB + LaFin(COL_Au[nLigne]) + TAB + Actif(COL_Au[nLigne])
FIN


comment puis-je generer un upload automatiquement sur le clic du bouton ?

merci

--
LH