Replace Excel data with openpyxl

Viewed 30

I have two excel sheets. One with formula and one without. Now I want to get the data from the Excel Sheet with Formula and replace it.

    data_read_only = list()
    wb = openpyxl.load_workbook(filename, data_only=True)
    ws = wb['Abschätzung SD Intern ']

    for row in ws.iter_rows():
        for cell in row:
            data_read_only.append(cell.value)




    wb: Workbook = openpyxl.load_workbook(filename, data_only=False)
    ws: Worksheet = wb['Abschätzung SD Intern ']

    for element in data_read_only:
        print(element)
        for row in ws.iter_rows():
            for cell in row:
                ws.cell(row=row, column=cell).value = element

    wb.save(filename)

How can I replace the rows?

0 Answers
Related