AttributeError: ‘Workbook’ object has no attribute ‘add_worksheet’

I was given a document that I run in Jupyter through Anaconda Navigator. The person who created the code is gone, and I am stuck. For over a year it was running fine daily. A couple of weeks ago Anaconda stopped working so IT reinstalled with the latest version. However, since then the document keeps failing at a certain part. I can continue on, but this portion does not produce the needed results. The code is below. Do I need to edit the code to prevent the error? I appreciate any help available.

> `productivity_flname = "%s/productivity_%s.xlsx" %(expath, fsuffix)
> with pd.ExcelWriter(productivity_flname) as writer:
> prod_book = writer.book
> prod_info_sheet = prod_book.add_worksheet('Info')
> prod_info_sheet.insert_textbox('A1', productivity_txt_bx, txt_bx_options)
> for row, data in enumerate(['Adjudicators'] + adjudicators):
> prod_info_sheet.write_string(row, 12, data)  
> for row, data in enumerate(['Peer Reviewers'] + peer_reviewers):
> prod_info_sheet.write_string(row, 13, data)
> prod_info_sheet.set_column("M:N", 18)    
> adj_ret.to_excel(writer, sheet_name="All Adjudicators", index = True)
> review_ret.to_excel(writer, sheet_name='All Peer Reviewers', index = True)
> for nm in adjudicators:
> print(nm)
> write_individuals(adj_ret, nm)
> for nm in peer_reviewers:
> print(nm)
> write_individuals(review_ret, nm)`
`AttributeError                            Traceback (most recent call last)
Cell In[16], line 7
      6 prod_book = writer.book
----> 7 prod_info_sheet = prod_book.add_worksheet('Info')
      8 prod_info_sheet.insert_textbox('A1', productivity_txt_bx, txt_bx_options)

AttributeError: 'Workbook' object has no attribute 'add_worksheet'

During handling of the above exception, another exception occurred:

IndexError                                Traceback (most recent call last)
Cell In[16], line 5
      1 ### write the report to an excel file
      2 ### as data for individual adjudicators and peer reviewers is written to the excel file, their names will appear below
      4 productivity_flname = "%s/productivity_%s.xlsx" %(expath, fsuffix)
----> 5 with pd.ExcelWriter(productivity_flname) as writer:
      6     prod_book = writer.book
      7     prod_info_sheet = prod_book.add_worksheet('Info')

File C:ProgramDataanaconda3Libsite-packagespandasioexcel_base.py:1322, in ExcelWriter.__exit__(self, exc_type, exc_value, traceback)
   1316 def __exit__(
   1317     self,
   1318     exc_type: type[BaseException] | None,
   1319     exc_value: BaseException | None,
   1320     traceback: TracebackType | None,
   1321 ) -> None:
-> 1322     self.close()

File C:ProgramDataanaconda3Libsite-packagespandasioexcel_base.py:1326, in ExcelWriter.close(self)
   1324 def close(self) -> None:
   1325     """synonym for save, to make it more file-like"""
-> 1326     self._save()
   1327     self._handles.close()

File C:ProgramDataanaconda3Libsite-packagespandasioexcel_openpyxl.py:109, in OpenpyxlWriter._save(self)
    105 def _save(self) -> None:
    106     """
    107     Save workbook to disk.
    108     """
--> 109     self.book.save(self._handles.handle)
    110     if "r+" in self._mode and not isinstance(self._handles.handle, mmap.mmap):
    111         # truncate file to the written content
    112         self._handles.handle.truncate()

File C:ProgramDataanaconda3Libsite-packagesopenpyxlworkbookworkbook.py:407, in Workbook.save(self, filename)
    405 if self.write_only and not self.worksheets:
    406     self.create_sheet()
--> 407 save_workbook(self, filename)

File C:ProgramDataanaconda3Libsite-packagesopenpyxlwriterexcel.py:293, in save_workbook(workbook, filename)
    291 archive = ZipFile(filename, 'w', ZIP_DEFLATED, allowZip64=True)
    292 writer = ExcelWriter(workbook, archive)
--> 293 writer.save()
    294 return True

File C:ProgramDataanaconda3Libsite-packagesopenpyxlwriterexcel.py:275, in ExcelWriter.save(self)
    273 def save(self):
    274     """Write data into the archive."""
--> 275     self.write_data()
    276     self._archive.close()

File C:ProgramDataanaconda3Libsite-packagesopenpyxlwriterexcel.py:89, in ExcelWriter.write_data(self)
     87 writer = WorkbookWriter(self.workbook)
     88 archive.writestr(ARC_ROOT_RELS, writer.write_root_rels())
---> 89 archive.writestr(ARC_WORKBOOK, writer.write())
     90 archive.writestr(ARC_WORKBOOK_RELS, writer.write_rels())
     92 self._merge_vba()

File C:ProgramDataanaconda3Libsite-packagesopenpyxlworkbook_writer.py:148, in WorkbookWriter.write(self)
    146 self.write_names()
    147 self.write_pivots()
--> 148 self.write_views()
    149 self.write_refs()
    151 return tostring(self.package.to_tree())

File C:ProgramDataanaconda3Libsite-packagesopenpyxlworkbook_writer.py:135, in WorkbookWriter.write_views(self)
    134 def write_views(self):
--> 135     active = get_active_sheet(self.wb)
    136     if self.wb.views:
    137         self.wb.views[0].activeTab = active

File C:ProgramDataanaconda3Libsite-packagesopenpyxlworkbook_writer.py:33, in get_active_sheet(wb)
     31 visible_sheets = [idx for idx, sheet in enumerate(wb._sheets) if sheet.sheet_state == "visible"]
     32 if not visible_sheets:
---> 33     raise IndexError("At least one sheet must be visible")
     35 idx = wb._active_sheet_index
     36 sheet = wb.active

IndexError: At least one sheet must be visible`

Usually this portion of the code will create an Excel workbook with multiple tabs. The first tab is just an info page, then a couple of cumulative tabs, and then individual breakdowns of the provided data. Overall, the whole document creates 5 different workbooks. I am just getting this error on this section and then again on another with the same error.your text

New contributor

Rick T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật