File corruption when opening file and saving under a different name
Created originally on Bitbucket by dunnski007
Hi,
I'm trying to debug an issue where openpyxl is saving an xlsm file and the output is always needing 'recovery' when it's being opened. (It's causing issues for automation for sending emaills.)
In order to debug, I made a test function and simply called one where the local files are hosted:
#!python
from openpyxl import Workbook
from openpyxl import load_workbook
import os
from openpyxl.chart import ( PieChart, Reference, BarChart3D, Series, label)
from openpyxl.chart.label import DataLabelList
def testExcel():
wb = load_workbook('.\file.xlsx', keep_vba=True)
newReport = 'testFile.xlsm'
wb.save(os.path.join('.\Reports', newReport))
This worked when I ran a single python function however when I call it as a function it causes file corruption and I cannot resolve that without manually re-saving the file.
Any input would be highly appreciated!