The below code is expected to set the top row to have a gray (#E7E6E6) background. However, where there is data it comes out with a white background and only is gray where there is no data. Anyone know is this is an unexpected outcome or a bug?
raw_data = {'regiment': ['Nighthawks', 'Nighthawks', 'Nighthawks', 'Nighthawks', 'Dragoons', 'Dragoons', 'Dragoons', 'Dragoons', 'Scouts', 'Scouts', 'Scouts', 'Scouts'],
'company': ['1st', '1st', '2nd', '2nd', '1st', '1st', '2nd', '2nd','1st', '1st', '2nd', '2nd'],
'name': ['Miller', 'Jacobson', 'Ali', 'Milner', 'Cooze', 'Jacon', 'Ryaner', 'Sone', 'Sloan', 'Piger', 'Riani', 'Ali'],
'preTestScore': [4, 24, 31, 2, 3, 4, 24, 31, 2, 3, 2, 3],
'postTestScore': [25, 94, 57, 62, 70, 25, 94, 57, 62, 70, 62, 70]}
report = pandas.DataFrame(raw_data, columns = ['regiment', 'company', 'name', 'preTestScore', 'postTestScore'])
location = 'C:/Desktop/'
writer = pandas.ExcelWriter(location+'Report.xlsx', engine='xlsxwriter')
# Convert the dataframe to an XlsxWriter Excel object.
REPORT.to_excel(writer,'Report',index=False)
# Get the xlsxwriter workbook and worksheet objects.
workbook = writer.book
worksheet = writer.sheets['Report']
# Add some cell formats.
format = workbook.add_format()
#format.set_bold()
format.set_bg_color('#E7E6E6')
worksheet.set_row(0, 18, format)
worksheet.set_column(0,1,25)
worksheet.set_column(2,2,8)
worksheet.set_column(3,3,21)
worksheet.set_column(4,5,25)
writer.save()