'Openpyxl breaking workbook?

I was wondering if anyone could shed some insight into why openpyxl is returning a broken workbook that needs repair.

I have a workbook saved at 'fileloc' that contains some pivot tables and charts. There is a sheet named 'data' that holds a data table (titled: 'Data') that the other sheets depend on.

When I run something as simple as

load workbook -> save workbook -> close workbook.

openpyxl returns a broken workbook and broken pivot tables.

Any idea on why this may be happening?

Code for reference:

import openpyxl
wb = openpyxl.load_workbook(fileloc)
wb.save(fileloc)
wb.close()

Errors for reference:

 - Removed Part: /xl/pivotTables/pivotTable1.xml part.  (PivotTable view)
 - We found a problem with some content...
 - fileloc is locked for editing by 'another user'

I'll add that I am the only user. I have also implemented a task kill function to make sure that all excel processes as closed.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source