Why do I get 'Merged Cell' object attribute 'value' is read only error on some Excel sheets but not others (overwriting data pandas and openpyxl)

14 hours ago 2
ARTICLE AD BOX

I'm currently designing a Python program for my boss that reads in schedule data from an Excel sheet and writes it to the employee's timesheets (also an Excel file). He wants the functions in the sheet to remain intact so I am using searching for matching dates using pandas and saving it to the file with excel_writer using "enging=openpyxl". This method worked completely fine during tests on random Excel files, but when trying to do the same thing to the employee timesheets I get the "'Merged Cell' object attribute 'value' is read only error".

It's my first time writing a program like this so I'm probably making a million mistakes, but if I can just get this working then I'll basically be done and meet my deadline for next week. I've done a lot of testing and the main thing I've seen is that this error only appears on some Excel sheets and not others, even within the same workbook. So "JAN 2026" works fine but "FEB 2026" does not, if that makes sense.

Here's my code. It loops through the values on the first column and searches for a date that matches the date found in the schedule. It then inserts the related hour count into the "Expected work hours" column. Please let me know what I'm doing wrong. I've looked at many answers to this question but none of them solved my particular issue.

df = pd.read_excel(filePath, sheet_name=worksheetName, skiprows=5) for item in workData: for row in range (0, len(df)): excelDate = df.iat[row, 0] if excelDate == item["date"]: df.iat[row, 7] = item["hours"] break with pd.ExcelWriter(filePath, engine='openpyxl', mode='a', if_sheet_exists='overlay') as writer: df.to_excel(writer, sheet_name=worksheetName, index=False, header=False, startrow=6)
Read Entire Article