Using the Openpyxl package, I'm attempting to delete a sheet from an Excel document, but the problematic Excel document contains links to other documents. When I access the Excel document after the application has run, I am informed that the file has been destroyed, notably because the original links that were in the Excel document have been removed.
The code I use is seen below:
def import_data(source_location, xplan_export, workbook):
os.chdir(source_location)
read_csv = pd.read_csv(xplan_export, encoding='latin-1')
# print(read_csv)
vworkbook= openpyxl.load_workbook(workbook, read_only=False)
sheet = vworkbook['Xplan_Export']
# clear Xplan Export sheet in workbook of interest
for row in sheet.iter_rows():
for cell in row:
cell.value = None
vworkbook.save(workbook)
I would like to get around this to ensure that the original links remain in the output of the functions above.