Skip to content Skip to sidebar Skip to footer

Update Rows And Column Using Openpyxl From Python

Problem: Add '(C)' or '(S)' in every column or row in an excel file by using openpyxl - python. Example of a patient record or list of exercises The list will have dozens if not hu

Solution 1:

You can use the cell function, see Accessing one cell in the documentation.

For example, assuming you've loaded the sheet into sheet1 and the details are in column one:

for row in range(1, sheet1.max_row+1):
    cell = sheet1.cell(row=row, column=1)
    if cell.value is not None:
        cell.value = "(c) " + cell.value

wb.save('test2.xlsx')

Post a Comment for "Update Rows And Column Using Openpyxl From Python"