Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DeprecationWarning: Call to deprecated function get_sheet_by_name (Use wb[sheetname])

When I executed the below code, I received a warning that reads " DeprecationWarning: Call to deprecated function get_sheet_by_name (Use wb[sheetname])." To avoid receiving the warning and execute the code properly, how do I need to fix the code?? Please help.

import openpyxl
wb=openpyxl.load_workbook('example.xlsx')
wb.get_sheet_names()
like image 261
John2 Avatar asked Jul 06 '18 04:07

John2


1 Answers

Use

wb.sheetnames

instead of

wb.get_sheet_names()

and use

wb["Sheet1"]

instead of

wb.get_sheet_by_name('Sheet1')
like image 54
rafaelc Avatar answered Sep 18 '22 20:09

rafaelc