Modify .xls file with python

656 Views Asked by At

Im coding a script in python that reads a excel file, then makes a change on a cell and then it copy all to another excel file and save it.

For example i have example.xls, then i generate example_copy.xls.

everuthing is the same, but my problem is, the formulas on the sheet are gone, when it makes a copy it keeps all the text but i want to copy all the formulas too.

I'm using xlutils to do this. This is part of my code:

def write_frecuencias(self):
    book = xlrd.open_workbook('Examen.xls', formatting_info=True)
    book_copy = copy(book)
    sheet = book_copy.get_sheet(0)
    frecuencies = self.get_frecuencias()
    row = 1
    for f in frecuencies:
        sheet.write(row, 1, str(f[0]))
        row += 1
    book_copy.save('Examen.xls')
0

There are 0 best solutions below