Color Specific Excel Cells Based On Match Condition In Python
I got an excel sheet with weekly data for number of people Sam Tony Michael 10 34 25 10 22 25 10 22 33 10 22 33 Requirement is to com
Solution 1:
Finally got the desired result:
import xlrd
import xlwt
from xlutils.copy import copy
from xlwt import Workbook
from xlrd import open_workbook
rb = open_workbook('test1.xlsx')
mysheet = rb.sheet_by_name('Sheet1')
numrows = mysheet.nrows
numcols = mysheet.ncols
value = ""
value1 = ""
col = 0
wb = copy(rb)
w_sheet = wb.get_sheet(0)
st = xlwt.easyxf('pattern: pattern solid;')
st.pattern.pattern_fore_colour = 4
while col < numcols:
value = mysheet.cell(1 , col)
for y in range(numrows-1):
y +=1
value1 = mysheet.cell(y , col)
value = str(value)
value1 = str(value1)
if (value1 != value):
w_sheet.write(y,col,value1,st)
else:
continue
col +=1
wb.save('output.xls')
Post a Comment for "Color Specific Excel Cells Based On Match Condition In Python"