write a xlsm file to a Dataiku folder

Thomas_11
Thomas_11 Registered Posts: 1
edited July 16 in Using Dataiku

I have an xlsm file and have loaded it from a Dataiku folder and changed a few cells using openpyxl. Now I would like to save it back to the Dataiku folder without loosing the macros. Is there a way to make the below work?

file = folder.get_download_stream(my_input_file_path)
output = BytesIO()
shutil.copyfileobj(file, output)
wb = openpyxl.load_workbook(output, read_only=False, keep_vba=True)
ws = wb[sheet_name]

ws['B2'] = 'something'
ws['X6'] = 'something else'       

wb.save('my_file.xlsm')
output.seek(0)

with folder.get_writer('my_file.xlsm') as writer:
    writer.write(output.read())
Tagged:

Answers

Setup Info
    Tags
      Help me…