Использование именованного стиля будет работать.
from openpyxl import *
from openpyxl.styles import *
#from openpyxl.styles.colors import RED #optional import for color names
from openpyxl import load_workbook
wb = load_workbook("./document.xlsx")
ws = wb.active
negative_style = NamedStyle(name='negativeStyle')
negative_style.font = Font(color = '00FF0000') #or color = RED, using import above
negative_style.alignment = Alignment(horizontal="right")
wb.add_named_style(negative_style)
for row in ws.iter_rows(min_col=1, max_col=1, max_row=10):
if cell.value < 0:
cell.value = f"({cell.value})" #If you want [ ] brackets, just change here to: f"[{cell.value}]"
cell.style = negative_style
wb.save('document.xlsx')
Вывод
Или, как указано в комментарии ниже, вы можете использовать Условное форматирование :
import openpyxl
from openpyxl import *
from openpyxl.formatting import Rule
from openpyxl.styles import Font, PatternFill, Border, Alignment
from openpyxl.formatting.rule import CellIsRule
wb = load_workbook("./document.xlsx")
ws = wb.active
ws.conditional_formatting.add('A1:C10', CellIsRule(operator='lessThan', formula=['0'],font = Font(color = '00FF0000')))
wb.save('document.xlsx')