Sep-23-2019, 12:08 PM
Hi Guys
I have got a set of table(FruitsTable, B2:E5) from excel and would like to the font color to be red for column B if quantity is > 6500 via using python.
However, I ran into a syntax error after typing the for loop and unable to find out what is the issue. Hence, would appreciate if you guys would assist with the code. Thanks in advance!
A B C D E
1 Fruits 2011 2012 2013 2014
2 Apples 10000 5000 8000 6000
3 Pears 20000 30000 4000 5000
4 Bananas 6000 6500 6700 6000
5 Oranges 500 300 200 700
I have got a set of table(FruitsTable, B2:E5) from excel and would like to the font color to be red for column B if quantity is > 6500 via using python.
However, I ran into a syntax error after typing the for loop and unable to find out what is the issue. Hence, would appreciate if you guys would assist with the code. Thanks in advance!
A B C D E
1 Fruits 2011 2012 2013 2014
2 Apples 10000 5000 8000 6000
3 Pears 20000 30000 4000 5000
4 Bananas 6000 6500 6700 6000
5 Oranges 500 300 200 700
from openpyxl import Workbook from openpyxl.styles import * from openpyxl.worksheet.table import Table, TableStyleInfo import openpyxl workbook = openpyxl.load_workbook("C:/Users/HAROLD/Desktop/Python 3/Automate excel data using python/Employees.xlsx") worksheet = workbook['Table'] style = TableStyleInfo(name = "TableStyleMedium9", showRowStripes = True, showColumnStripes = True) table.tableStyleInfo = style font = Font(color = colors.RED, bold = True, italic = Bold) for cell_number in range (2,6): if int(worksheet['B%s' % (cell_number)].value > 6500: