# -*- coding: iso-8859-1 -*- #. // _ca_BackColor.py #. // Définit une couleur à une ou plusieurs cellules. def ca_BackColor( oSheet, nColor, nRowFrist, nColFrist, nRowLast = None, nColLast = None ): if nRowLast is None: nRowLast = nRowFrist #. endif if nColLast is None: nColLast = nColFrist #. endif oSheet.getCellRangeByPosition( nColFrist - 1, nRowFrist - 1 , nColLast - 1, nRowLast - 1 ).CellBackColor = nColor return 0 ''' Dernière modification : 2022-02-20 [Exemple] import sys sys.path.append( "modules" ) from _ca_BackColor import ca_BackColor # // Définit une couleur à une ou plusieurs cellules. from _by_ConstColorsRGB import by_ConstColorsRGB # // Constantes pour les couleurs RGB. from _ca_AutoFit import ca_AutoFit # // Règle les dimensions des cellules utilisées. from _ca_WriteFormula import ca_WriteFormula # // Ecrit une formule dans une cellule avec options. from _lo_LibreOfficeNew import lo_LibreOfficeNew # // Ouvre Libre Office. from _lo_MakeProperty import lo_MakeProperty # // Créer une propriété Libre Office. oServiceManager = lo_LibreOfficeNew() if oServiceManager is None: quit() args1 = lo_MakeProperty( oServiceManager, "Hidden", False ) oDesktop = oServiceManager.createInstance( "com.sun.star.frame.Desktop" ) oDoc = oDesktop.loadComponentFromURL( "private:factory/scalc", "_blank", 0, [ args1 ] ) oSheet = oDoc.GetSheets().GetByIndex( 0 ) aColors = by_ConstColorsRGB() ca_WriteFormula( oSheet, 1, 1, "Couleur de fond Blue4" ) ca_BackColor( oSheet, aColors[ "Blue4" ], 1, 2 ) ca_WriteFormula( oSheet, 2, 1, "Couleur de fond Turquoise1" ) ca_BackColor( oSheet, aColors[ "Turquoise1" ], 2, 2 ) ca_WriteFormula( oSheet, 3, 1, "Couleur de fond Gray10" ) ca_BackColor( oSheet, aColors[ "Gray10" ], 3, 2 ) ca_AutoFit( oSheet ) aColors = {} oServiceManager = None [/Exemple] '''