# -*- coding: iso-8859-1 -*- #. // _ex_InsertImage.py #. // Insérer une image. from _by_IntToCell import by_IntToCell # // Transforme une cellule Row, Col en caractère. def ex_InsertImage( oSheet, nRow, nCol, cFile ): oImg = oSheet.Pictures().Insert( cFile ) cCell = by_IntToCell( nRow, nCol ) oImg.Top = oSheet.Range( cCell ).Top oImg.Left = oSheet.Range( cCell ).Left return 0 ''' Dernière modification : 2022-02-24 [Todo] Faire la taille de l'image. [Exemple] from _ex_InsertImage import ex_InsertImage # // Insérer une image. from _by_getfile import by_getfile # // Sélectionner un fichier à ouvrir. from _ex_AutoFit import ex_AutoFit # // Ajuste la taille des cellules. from _ex_ExcelNew import ex_ExcelNew # // Ouvre Excel. cFile = by_getfile( "Fichiers jpg\0*.jpg\0Tous fichiers\0*.*" , "Sélectionnez une image" ) if len( cFile ) == 0: print() print( "Pas d'image sélectionnée, abandon." ) quit() oExcel = ex_ExcelNew() oBook = oExcel.Workbooks.Add() oSheet = oBook.Worksheets( 1 ) oSheet.Cells( 1, 1 ).Formula = 'Insérer une image' ex_InsertImage( oSheet, 3, 2, cFile ) ex_AutoFit( oSheet ) oExcel.DisplayAlerts = False oExcel = None [/Exemple] '''