deleting sheet results in unreadable workbook
Created originally on Bitbucket by beerdedfellow (Ryan Hutchison)
Hello,
Firstly, thank you for your work on this module, great utility! My issue seems strikingly similar to #446 (closed). Currently I am using the following loop to pull sheets from the template that have not been populated:
for sheet in self.wb.worksheets:
if sheet['B6'].value is None:
del self.wb[sheet.title]
When attempting to open the workbook, I get a "content not readable" error. Reviewing the log reveals that a named range was removed to repair the file:
<removedFeature>Removed Feature: Named range from /xl/workbook.xml (Workbook)</removedFeature></removedFeatures></recoveryLog>
Looking at the referenced issue, it looks as though named ranges may have been the cause. In inspecting the archive, it looks as though some named ranges were indeed left behind after the delete:
<workbook
xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<workbookPr codeName="ThisWorkbook"/>
<bookViews>
<workbookView/>
</bookViews>
<sheets>
<sheet
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" name="IAD" sheetId="1" state="visible" r:id="rId1"/>
</sheets>
<definedNames>
<definedName localSheetId="0" name="DISCOUNT">DFW!$G$39:$G$45</definedName>
<definedName localSheetId="1" name="DISCOUNT">IAD!$G$39:$G$45</definedName>
<definedName localSheetId="2" name="DISCOUNT">ORD!$G$39:$G$45</definedName>
<definedName localSheetId="3" name="DISCOUNT">SYD!$G$39:$G$45</definedName>
<definedName name="DISCOUNT">HKG!$G$39:$G$45</definedName>
</definedNames>
<calcPr calcId="124519" fullCalcOnLoad="1"/>
</workbook>
Please let me know if there is any other information you need!
Attachments: pricing_template_issue.xlsx