简体   繁体   中英

Is it possible to overwrite existing data in .xlsx file with openpyxl?

Say I want to update som data in example1.xlsx. Is this possible to do using openpyxl without having to save it as a new file?

As far as I can tell you can open a workbook with openpyxl, modify some data, then save the workbook in place:

wb = openpyxl.load_workbook('path\\to\\workbook.xlsx')
c = wb['Sheet1']['A1']
c.value = 'hello'
wb.save('path\\to\\workbook.xlsx')

If you're saying that your workbook is too big to manipulate in this way, it looks as if you would have to open it in read-only mode , manipulate the data as you read it in, and write it to a new workbook in write-only mode .

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