# -*- coding: iso-8859-1 -*- #. // _ex_ColumnMove.py #. // Déplacer une colonne avant une autre. from _by_IntToCol import by_IntToCol # // Transforme une colonne nCol en caractère. def ex_ColumnMove( oSheet, nColOld, nColNew ): cColNew = by_IntToCol( nColNew ) + ":" + by_IntToCol( nColNew ) cColOld = by_IntToCol( nColOld + 1 ) + ":" + by_IntToCol( nColOld + 1 ) oSheet.Range( cColNew ).Insert() oSheet.Range( cColOld ).Copy( oSheet.Range( cColNew ) ) oSheet.Range( cColOld ).Delete() return 0 ''' Dernière modification : 2022-03-03 from _ex_ColumnMove import ex_ColumnMove # // Déplacer une colonne avant une autre. from _by_IntToCol import by_IntToCol # // Transforme une colonne nCol en caractère. from _ex_ExcelNew import ex_ExcelNew # // Ouvre Excel. oExcel = ex_ExcelNew() oBook = oExcel.Workbooks.Add() oSheet = oBook.Worksheets( 1 ) oSheet.Activate() l = 1 for c in range( 1, 10, 1 ): oSheet.Cells( l, c ).Formula = "1 - Col " + by_IntToCol( c ) ex_ColumnMove( oSheet, 5, 1 ) l += 1 for c in range( 1, 10, 1 ): oSheet.Cells( l, c ).Formula = "2 - Col " + by_IntToCol( c ) oExcel.DisplayAlerts = False oExcel = None '''