Horizontal text alignment in openpyxl

后端 未结 4 1452
迷失自我
迷失自我 2021-02-07 05:48

I\'m tryign to change the text alignment to the center of 2 merged sells, I\'ve found some answers that didn\'t work for my case

currentCell = ws.cell(\'A1\')
cu         


        
4条回答
  •  耶瑟儿~
    2021-02-07 06:21

    yes, there is a way to do this with openpyxl:

    from openpyxl.styles import Alignment
    
    currentCell = ws.cell('A1') #or currentCell = ws['A1']
    currentCell.alignment = Alignment(horizontal='center')
    

    hope this will help you

提交回复
热议问题