0

I'm trying to find a convenient way to copy value from Excel spreadsheet cell after I edited it with openpyxl where I put formula, and paste that value as a value to another cell in the same spread sheet.

However, for some reason I always get a formula instead of value when I paste it. I was trying to copy only value by using .value, like in code below:

import openpyxl
from openpyxl import load_workbook, Workbook

wb = load_workbook['C://Path.xlsx']
ws = wb['Sheet1']
ws['A120'] = '=ROUND(SUM(A1:A119), 2)'
ws['C2'] = ws['A120'].value
wb.save('C://Path.xlsx')
wb.close()

But the value isn't copied and it returns only formula. My question is why openpyxl doesn't recognize newly created value and can not copy it as value?

Is there a way to do it in a simple and convenient way?

Thank you for you answers in advance

  • See [this question](https://stackoverflow.com/questions/28517508/read-excel-cell-value-and-not-the-formula-computing-it-openpyxl) and its answers. – import random Oct 21 '22 at 14:42

0 Answers0