I am trying to read the cell of a excel file in python, change its value and save it. If I do not have the line from xlutils.copy import copy
in code, it recognizes workbook.sheeets()
, but otherwise it says
AttributeError: 'Workbook' object has no attribute 'sheets'
Here is my code:
from xlutils.copy import copy
import xlrd
st = xlwt.easyxf('pattern: pattern solid;')
rb = xlrd.open_workbook('00-17.xlsx')
workbook = copy(rb)
for sheet in workbook.sheets():
for row in range(sheet.nrows):
current_value = sheet.cell(row,3).value
if(current_value == '1' ) :
st.pattern.pattern_fore_colour = 5
for column in [0,2,3]:
value = sheet.cell(row, column).value
print value
sheet.write(row, column, value,st)
workbook.save('1.xlsx')