[VB6]créer un fichier excel
Bonjour,
J'ai une application VB6 avec BDD Oracle.
J'ai une page qui permet de consulter les effectifs d'une entreprise.
Il faudrait que je puissent exporter les données de cette page vers une feuille excel (j'ai vu ce genre de chose dans le forum mais avec un TDBGrid et je ne vois pas comment adapter)
Voici les requêtes qui me permettent d'afficher les effectifs voulu. Comment créer ma feuille excel à partir de ça ?
Code:
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 102 103 104 105 106 107 108
| '---------------------
' CALCUL DES EFFECTIFS
'---------------------
'-----------------------------
' Effectif en début de période
'-----------------------------
SQL1 = " SELECT COUNT(DISTINCT CODE_PERSONNEL) AS NB_EFFECTIF_DEB " & _
" FROM PERSONNEL " & _
" WHERE (PERSONNEL_ALTECA = 1 OR (NATURE_CONTRAT = 'Intérimaire') and (REMPLACE = '' or REMPLACE is null)) " & _
" AND DATE_EMBAUCHE_PERSONNEL<'" & DateDeb & "'" & _
" AND (DATE_DEBAUCHE_PERSONNEL>='" & DateDeb & "' OR DATE_DEBAUCHE_PERSONNEL IS NULL)"
If SuiviPersonnel_Form.SelectAgence(1).Value Then
SQL1 = SQL1 & _
" AND CODE_AGENCE_PERSONNEL=" & SuiviPersonnel_Form.ChoixAgence.BoundText
End If
' SAN 23/02/06 fiche GIN 69 ajout des critères "type de contrat" et "profil personnels"
If SuiviPersonnel_Form.SelectContrat(0).Value = True Then
SQL1 = SQL1 & _
" AND NATURE_CONTRAT='CDI' "
End If
If SuiviPersonnel_Form.SelectProfil(0).Value = True Then
SQL1 = SQL1 & _
" AND STRUCTURE = 0 and RESPONSABLE_CONTRAT=0 "
End If
'fin SAN
Set rsNbEffectif.ActiveConnection = AccesBD.Gest
rsNbEffectif.Open SQL1
SuiviPersonnel_Form.TextEffectifDeb.Text = rsNbEffectif![NB_EFFECTIF_DEB]
rsNbEffectif.Close
'---------------------------
' Effectif en fin de période
'---------------------------
SQL1 = " SELECT COUNT(DISTINCT CODE_PERSONNEL) AS NB_EFFECTIF_FIN " & _
" FROM PERSONNEL " & _
" WHERE (PERSONNEL_ALTECA = 1 OR (NATURE_CONTRAT = 'Intérimaire') and (REMPLACE = '' or REMPLACE is null)) " & _
" AND DATE_EMBAUCHE_PERSONNEL<='" & datefin & "'" & _
" AND (DATE_DEBAUCHE_PERSONNEL>'" & datefin & "' OR DATE_DEBAUCHE_PERSONNEL IS NULL)"
If SuiviPersonnel_Form.SelectAgence(1).Value Then
SQL1 = SQL1 & _
" AND CODE_AGENCE_PERSONNEL=" & SuiviPersonnel_Form.ChoixAgence.BoundText
End If
' SAN 23/02/06 fiche GIN 69 ajout des critères "type de contrat" et "profil personnels"
If SuiviPersonnel_Form.SelectContrat(0).Value = True Then
SQL1 = SQL1 & _
" AND NATURE_CONTRAT='CDI' "
End If
If SuiviPersonnel_Form.SelectProfil(0).Value = True Then
SQL1 = SQL1 & _
" AND STRUCTURE = 0 and RESPONSABLE_CONTRAT=0 "
End If
'fin SAN
Set rsNbEffectif.ActiveConnection = AccesBD.Gest
rsNbEffectif.Open SQL1
SuiviPersonnel_Form.TextEffectifFin.Text = rsNbEffectif![NB_EFFECTIF_FIN]
Eff_Fin = rsNbEffectif![NB_EFFECTIF_FIN]
rsNbEffectif.Close
'------------------
' Nombre de départs
'------------------
SQL1 = " SELECT COUNT(DISTINCT CODE_PERSONNEL) AS NB_DEPART " & _
" FROM PERSONNEL " & _
" WHERE (PERSONNEL_ALTECA = 1 OR (NATURE_CONTRAT = 'Intérimaire') and (REMPLACE = '' or REMPLACE is null)) " & _
" AND DATE_DEBAUCHE_PERSONNEL>='" & DateDeb & "'" & _
" AND DATE_DEBAUCHE_PERSONNEL<='" & datefin & "'" & _
" AND MOTIF_DEPART <> 'Mutation' " ' SAN : On ne veut pas comptabiliser une mutation comme un départ
'Attention, en réalité,les mutations sont saisies dans l'historique des postes d'un personnel
'SQL1 = " SELECT COUNT(DISTINCT CODE_PERSONNEL) AS NB_DEPART " & _
' " FROM PERSONNEL, HISTORIQUE " & _
' " WHERE (PERSONNEL_ALTECA = 1 OR (NATURE_CONTRAT = 'Intérimaire') and (REMPLACE = '' or REMPLACE is null)) " & _
' " AND DATE_DEBAUCHE_PERSONNEL>='" & DateDeb & "'" & _
' " AND DATE_DEBAUCHE_PERSONNEL<='" & datefin & "'" & _
' " AND MOTIFDEPART_HISTORIQUE <> 'Mutation' " & _
' " AND CODEPERSONNEL_HISTORIQUE=CODE_PERSONNEL"
If SuiviPersonnel_Form.SelectAgence(1).Value Then
SQL1 = SQL1 & _
" AND CODE_AGENCE_PERSONNEL=" & SuiviPersonnel_Form.ChoixAgence.BoundText
End If
' SAN 23/02/06 fiche GIN 69 ajout des critères "type de contrat" et "profil personnels"
If SuiviPersonnel_Form.SelectContrat(0).Value = True Then
SQL1 = SQL1 & _
" AND NATURE_CONTRAT='CDI' "
End If
If SuiviPersonnel_Form.SelectProfil(0).Value = True Then
SQL1 = SQL1 & _
" AND STRUCTURE = 0 and RESPONSABLE_CONTRAT=0 "
End If
'fin SAN
Set rsNbEffectif.ActiveConnection = AccesBD.Gest
rsNbEffectif.Open SQL1
NbDepart = rsNbEffectif![NB_DEPART]
rsNbEffectif.Close
'-------------------
' Calcul du turnover
'-------------------
If Eff_Fin = 0 Then
SuiviPersonnel_Form.TextTurnover.Text = "-"
Else
temp = NbDepart / Eff_Fin
SuiviPersonnel_Form.TextTurnover.Text = Format(temp, "0.00%") ' fonction permettant de multiplier par 100
End If
SuiviPersonnel_Form.txtEvolutionEffectif.Text = Eff_Fin - val(SuiviPersonnel_Form.TextEffectifDeb.Text)
' Une fois la requête exécutée, le bouton imprimer devient visible
SuiviPersonnel_Form.cmdImprimer.Visible = True |
Merci de votre aide
EditT'as pas lu les règles du forum :evil: Alors voilà, pour que ton code soit lisible, tu sélectionnes ton code et tu fais un clic sur le bouton Code en haut de la fenêtre d'édition de ton message :wink:
Ceci dit, bienvenue sur le forum
Balises Code /code ajoutées par ouskel'n'or
Désolée pour les balises code ... j'avais lu les règles mais la dernière fois que j'ai effectué des recherches ...
encore besoin d'un export excel
Toujours pour la même application en VB6, j'ai un concepteur (état VB) qui me renvoie la liste des personnels. C'est état VB peut être exporté en HTML, mais il faudrait pouvoir l'exporter en EXCEL. Comment pourrai-je faire? faut-il que je crée un nouvel état avec crystal report?
Voici une partie du code pour mettre en forme l'état VB
Code:
1 2 3 4 5
| Liste_Ingenieur.Sections("Section2").Controls("Shape17").Visible = EditionsPersonnel_Form.chkNomPrenom.Value
Liste_Ingenieur.Sections("Section2").Controls("lblCol1").Visible = EditionsPersonnel_Form.chkNomPrenom.Value
Liste_Ingenieur.Sections("Section1").Controls("txtNomPrenom").Visible = EditionsPersonnel_Form.chkNomPrenom.Value
Liste_Ingenieur.Sections("Section1").Controls("Shape1").Visible = EditionsPersonnel_Form.chkNomPrenom.Value
If EditionsPersonnel_Form.chkNomPrenom.Value <> 1 Then MargeG = 0 Else MargeG = Liste_Ingenieur.Sections("Section2").Controls("Shape17").Width + 60 |
Voici le code pour afficher l'état (il s'affiche directement avec la possibilité d'exporter en HTML)
Code:
Liste_Ingenieur.Show vbModal