Index out of range error in wb.save() in xlutils

255 views
Skip to first unread message

Shubham Agrawal

unread,
Jan 22, 2021, 4:20:21 AM1/22/21
to python-excel
Hi Guys,

I am using "copy"function in xlutils to copy data from one workbook to another. Then I am filtering out the sheets from the workbook but when I execute wb.save() I am getting the following error:


Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/xlwt/Workbook.py", line 710, in save
    doc.save(filename_or_stream, self.get_biff_data())
  File "/usr/local/lib/python3.8/site-packages/xlwt/Workbook.py", line 680, in get_biff_data
    self.__worksheets[self.__active_sheet].selected = True
IndexError: list index out of range

Here is the code that I am trying to execute:

wb = copy(rb)
code = client.code
wb._Workbook__worksheets = [ worksheet for worksheet in wb._Workbook__worksheets if worksheet.name == code ]
wb.save(response)
Reply all
Reply to author
Forward
0 new messages