How to get excel sheet name in Python using xlrd

微笑、不失礼 提交于 2019-11-30 21:56:42

I have modified the code I gave as a question and have got what I needed actually,

def getSheetName(file_name):
    pointSheetObj = []
    import xlrd as xl
    TeamPointWorkbook = xl.open_workbook(file_name)
    pointSheets = TeamPointWorkbook.sheet_names()

    for i in pointSheets:
        pointSheetObj.append(tuple((TeamPointWorkbook.sheet_by_name(i),i)))

so if the list (of tuple) pointSheetObj is iterated we have name of the sheet at index 1 of the tuple inside the pointSheetObj.

By doing this I have got the name and the worksheet object with which I can carry on with other sheet related methods.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!