NameError: global name 'worksheet' is not defined when using SheetProtection

Issue #630 resolved
lansman
created an issue
wb = opx.Workbook(write_only=True)
ws = wb.create_sheet("test")
protection = opx.worksheet.protection.SheetProtection()
protection.enable()
ws.protection = protection
wb.save("test.xlsx")
Traceback (most recent call last):
  File "C:/Users/user/.PyCharm2016.1/config/scratches/scratch_7.py", line 11, in <module>
    wb.save("test.xlsx")
  File "C:\Python27\ArcGIS10.2\lib\site-packages\openpyxl\workbook\workbook.py", line 261, in save
    save_dump(self, filename)
  File "C:\Python27\ArcGIS10.2\lib\site-packages\openpyxl\writer\write_only.py", line 248, in save_dump
    writer.save(filename)
  File "C:\Python27\ArcGIS10.2\lib\site-packages\openpyxl\writer\excel.py", line 222, in save
    self.write_data(archive, as_template=as_template)
  File "C:\Python27\ArcGIS10.2\lib\site-packages\openpyxl\writer\excel.py", line 80, in write_data
    self._write_worksheets(archive)
  File "C:\Python27\ArcGIS10.2\lib\site-packages\openpyxl\writer\excel.py", line 163, in _write_worksheets
    xml = sheet._write(self.workbook.shared_strings)
  File "C:\Python27\ArcGIS10.2\lib\site-packages\openpyxl\writer\write_only.py", line 216, in _write
    self.close()
  File "C:\Python27\ArcGIS10.2\lib\site-packages\openpyxl\writer\write_only.py", line 147, in close
    self.writer.close()
  File "C:\Python27\ArcGIS10.2\lib\site-packages\openpyxl\writer\write_only.py", line 122, in _write_header
    xf.write(worksheet.protection.to_tree())
NameError: global name 'worksheet' is not defined

openpyxl 2.3.5

Comments (4)

  1. Log in to comment