GIVE:
Utiliser des fonctions Python
dans Excel.
- Python ou VBA?
- Installation
- Exemples
- Perspectives
30/10/2017
Python ou VBA?
30/10/2017 GIVE: utiliser des fonctions Python dans Excel 2>
VS
VBA
+ Automatisation de tâches facile sous Excel, Word…
+ Code adapté pour certaines manipulations dans Excel
Python
+ Langage très simple et facile à apprendre
+ fichiers de code distinct des fichiers Excel.
+ Nombreux modules disponibles (calcul matriciel, graphiques…)
+ Réutilisation possible avec d’autres logiciels (Pythagore, Revit, Rhino…)
30/10/2017 GIVE: utiliser des fonctions Python dans Excel 3>
Installation
30/10/2017 GIVE: utiliser des fonctions Python dans Excel 4>
Installation pas à pas
1- Installer la distribution anaconda
Contient: Python + Xlwings + de nombreux modules utiles
30/10/2017 GIVE: utiliser des fonctions Python dans Excel 5>
Installation pas à pas
2-Spécifier chemin d’accès python à windows
C:\Users\jean-remi.baer\AppData\Local\Continuum\Anaconda3
30/10/2017 GIVE: utiliser des fonctions Python dans Excel 6>
Installation pas à pas
3-Installation de l’add-in Excel xlwings
Contient: Python + Xlwings + de nombreux modules utiles
Rentrer dans l’invite de commande:
Taper xlwings addin install
Un nouvel onglet dans le ruban Excel devrait s’afficher:
30/10/2017 GIVE: utiliser des fonctions Python dans Excel 7>
Installation pas à pas
4-Configuration Excel (1)
Ouvrir le module VBA avec CTRL+F11
Cocher la case xlwings dans OutilsRéférences
30/10/2017 GIVE: utiliser des fonctions Python dans Excel 8>
Installation pas à pas
4-Configuration Excel (2):
Dans les options Excel, cocher: accès approuvé au modèle d’objet du projet VBA
30/10/2017 GIVE: utiliser des fonctions Python dans Excel 9>
Installation pas à pas
5-Configurer ruban add-in Excel
PYTHONPATH: chemin d’accès du module python (répertoire du fichier Excel
par défaut)
UDF modules: nom du module python à utiliser
30/10/2017 GIVE: utiliser des fonctions Python dans Excel 10 >
Exemples
30/10/2017 GIVE: utiliser des fonctions Python dans Excel 11 >
Exemples (1)
Fonction d’interpolation
30/10/2017 GIVE: utiliser des fonctions Python dans Excel 12 >
Exemple (2)
3- Graphiques avec le module matplotlib
30/10/2017 GIVE: utiliser des fonctions Python dans Excel 13 >
Perspectives
30/10/2017 GIVE: utiliser des fonctions Python dans Excel 14 >
- Remplacer VBA par Python: maintenance et partage plus facile du code
- Création d’une bibliothèque mutualisée de fonctions métiers.
- Ré-emploi des fonctions python pour d’autres logiciels (Pythagore,
Revit, Rhino…)
Ressources:
-site anaconda: https://www.anaconda.com/download/
-doc xlwings: http://docs.xlwings.org/en/stable/matplotlib.html
-tutoriel python: https://python.developpez.com/cours/apprendre-python3/
Immeuble le Crystallin
191-193 cours Lafayette
CS 20087
69458 LYON cedex 6