Reputation: 1
I have a requirement that replaces excel cell value(string/text) with "X" and doesn't replace it if it is empty.
Upvotes: 0
Views: 344
Reputation: 902
Given that no use case or details are provided, see if this is what you want.
import openpyxl
wb = openpyxl.load_workbook('input.xlsx')
ws = wb.worksheets[0]
for row in ws.iter_rows():
for cell in row:
if cell.value != None:
cell.value = 'X'
wb.save('output.xlsx')
Upvotes: 2