colorset.py
import openpyxl
from openpyxl.styles import PatternFill, colors
from demo.src.demo.Data_Process import readCashFlowlAdjuestmentFilexlsx
ffnpath = r’C:\wz\pythonFile\crashflow_sg_template_Weekly.xlsx’
ffnpath = r’C:\Users\Public\pythonFile1\crashflow_sg_template_Weekly.xlsx’
wb = openpyxl.load_workbook(ffnpath,data_only=True)
fill_3 = PatternFill(“solid”, fgColor=colors.RED)
names = wb.sheetnames
sheet = wb[names[0]]
sht = wb.worksheets[0]
str1 = []
for one_column_data in sheet.iter_rows():
print(one_column_data[7].value)
if one_column_data[7].value == None:
str1.append(1)
else:
str1.append(‘no fill’)
print(str1)
for x in range(len(str1)):
if str1[x] == 1:
strx = str(x+1)
Ax = “A” + strx
Bx = “B” + strx
Cx = “C” + strx
Dx = “D” + strx
Ex = “E” + strx
Fx = “F” + strx
Gx = “G” + strx
Hx = “H” + strx
Ix = “I” + strx
jx = “j” + strx
Kx = “K” + strx
Lx = “L” + strx
Mx = “M” + strx
Nx = “N” + strx
Ox = “O” + strx
Px = “P” + strx
Qx = “Q” + strx
Rx = “R” + strx
print(Ax)
sht[Ax].fill = fill_3
sht[Bx].fill = fill_3
sht[Cx].fill = fill_3
sht[Dx].fill = fill_3
sht[Ex].fill = fill_3
sht[Fx].fill = fill_3
sht[Gx].fill = fill_3
sht[Hx].fill = fill_3
sht[Ix].fill = fill_3
sht[jx].fill = fill_3
sht[Kx].fill = fill_3
sht[Lx].fill = fill_3
sht[Mx].fill = fill_3
sht[Nx].fill = fill_3
sht[Ox].fill = fill_3
sht[Px].fill = fill_3
sht[Qx].fill = fill_3
sht[Rx].fill = fill_3
print(‘fill done!’)
wb.save(ffnpath)
import os
os.startfile(ffnpath)