from openpyxl import load_workbook
from openpyxl.styles import *

def style(file):
    wb = load_workbook(file)
    ws = wb.active
    for row in ws.iter_rows():
        for cell in row:
            if cell is not None:
                cell.alignment = Alignment(horizontal='center',vertical='center')
    wb.save(file)
        
style('测试3.xlsx')