No other solutions worked for me, since my solution requires openpyxl, and at least in 2.1.5 cell.alignment cannot be set directly.
from openpyxl.styles import Style, Alignment cell = ws.cell('A1') cell.style = cell.style.copy(alignment=Alignment(horizontal='center'))
The above instance copies the current style and replaces the alignment. You can also create a completely new style - with any values not specified using the default values from https://openpyxl.readthedocs.org/en/latest/styles.html
cell.style = Style(alignment=Alignment(horizontal='center'),font=Font(bold=True)) # or - a tidier way vals = {'alignment':Alignment(horizontal='center'), 'font':Font(bold=True), } new_style = Style(**vals) cell.style = new_style
source share