# -*- coding: iso-8859-1 -*- #. // _ex_Sort.py #. // Trie des colonnes. from _by_IntToCol import by_IntToCol # // Transforme une colonne nCol en caractère. from _ex_LastCell import ex_LastCell # // Dernière cellule d'une feuille. from _ex_LastRow import ex_LastRow # // Dernière ligne d'une feuille. xlAscending = 1 xlDescending = 2 xlNo = 2 xlYes = 1 xlSortOnValues = 0 xlSortNormal = 0 xlTopToBottom = 1 xlPinYin = 1 def ex_Sort( oSheet # // Objet feuille( Sheet ). , lHeader # // True si titres. , aSort # // Tableau des tris : cCol | nCol, True si ascendent. , lCase = False # // Facultatif : True pour respecter majuscules et minuscules. ): if lHeader: nHeader = xlYes cFirstRow = "2" else: nHeader = xlNo cFirstRow = "1" #. endif cLastRow = str( ex_LastRow( oSheet ) ) oSheet.Sort.SortFields.Clear() for i in range( 0, len( aSort ), 2 ): if type( aSort[ i ] ) is str: cCol = aSort[ i ] else: cCol = by_IntToCol( aSort[ i ] ) #. endif if aSort[ i + 1 ]: nTri = xlAscending else: nTri = xlDescending #. endif oSheet.Sort.SortFields.Add( oSheet.Range( cCol + cFirstRow + ":" +cCol + cLastRow ) , xlSortOnValues , nTri , xlSortNormal ) #. endfor oSheet.Sort.SetRange( oSheet.Range( "A1:" + ex_LastCell( oSheet ) ) ) oSheet.Sort.Header = nHeader oSheet.Sort.MatchCase = lCase oSheet.Sort.Orientation = xlTopToBottom oSheet.Sort.SortMethod = xlPinYin oSheet.Sort.Apply() return 0 ''' Dernière modification : 2022-03-04 from _ex_Sort import ex_Sort # // Trie des colonnes. '''