0

I need to update an xlsm file using python from a DataFrame. How can I modify that file without errors? My principal problem is this: I overwrite the file and save it, and I when go to open it, the file is corrupt and I can't open it.

def write_data(self, sheet, col_start, row_start):
        with ExcelWriter('TEST.xlsm') as writer:
            self.get_data2post(sheet).to_excel(writer,
                                               startcol = col_start,
                                               startrow = row_start,
                                               sheet_name = sheet,
                                               header = False,
                                               index = False)
        writer.save()
        writer.close()
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73

1 Answers1

0

At the moment, it can't save an excel file with macros from pandas or ExcelWriter. So, I've had to use a different library, _openpyxl_ and with this, I can read and write an excel file with macros, but... this has a few problems like losing some images, and formulas are not calculated