简体   繁体   中英

updating cell's value in excel file using openpyxl without over writing with python

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")

Try this:

c1.value = c1.value + "\n" + ANKIT"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM