I am entering in a simple string to a worksheet on an existing workbook to signify that no exceptions have been found in the code for that particular business check - 'No Data to Display'
I have the below code in order to do this but for some reason, when I use the referenced save path from the config file 'config.sod_report_full_name' it doesn't save the text in the cell.
If I hard code the save path as a normal string it does work... but I can't use this way as the save path is dynamic.
file_source = config.sod_report_full_name
workbook = openpyxl.load_workbook(filename=file_source)
worksheet = workbook['Shareclass Check 2']
print("Writing - No Data to Display")
worksheet['C5'] = 'No Data to Display'
workbook.template = False
workbook.save(file_source)
workbook.close()
print("No exceptions for Shareclass 2 check")
The openpyxl was classing with my writer method causing an overwrite to occur on the spreadsheet.
Created a datafram and trimmed to one cell and pasted in using writer instead.