Reputation: 143
I want to update cell in excel file without over writing . I want to insert the new data into the same cell. the following code as example: the old value is "RAI", I want to add "ANKIT" without over writing. so the cell's value become : "RAI", "ANKIT"
# import openpyxl module
import openpyxl
wb = openpyxl.Workbook()
sheet = wb.active
c1 = sheet.cell(row = 1, column = 1)
c1.value = "ANKIT"
wb.save("C:\\Users\\user\\Desktop\\demo.xlsx")
Upvotes: 0
Views: 5936
Reputation: 2086
Try this:
if c1.value:
c1.value = c1.value + "\n" + "ANKIT"
else:
c1.value = "\n" + "ANKIT"
Upvotes: 1