OpenPyxl Cell.value Alignment - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: OpenPyxl Cell.value Alignment (/thread-12730.html) |
OpenPyxl Cell.value Alignment - pcsailor - Sep-10-2018 Hi, I am using OpenPyXl and need to align different cells with different alignment values (center, right, bottom, etc.). My code seems to be ignoring my if statements. The center alignment is working. Any clue what's wrong with the If statement? (I've also tried this: if sheet['A1':'I43'] == 'Hz':) # Cell Alignment al = Alignment(horizontal='center', vertical='center') br = Alignment(horizontal='right', vertical='bottom') for row in sheet['A1':'I43']: for cell in row: if cell == 'Hz': cell.alignment = br else: cell.alignment = alThanks, Phil |