python 读取excel表中sheetname的两种方法

1. 

import xlrd

b=xlrd.open_workbook(r"D:###.XLSX")
count=len(b.sheets())
for sheet in b.sheets():
    print sheet.name

2.

import win32com.client as win32


filepath=os.path.join(r"d:#####.xlsx")
xlapp=win32.gencache.EnsureDispatch('Excel.Application')
xlapp.Visible= False
sheetName = xlapp.Workbooks.Open(filepath).Sheets(1).Name
print sheetName 

  

原文地址:https://www.cnblogs.com/ling-share/p/4892415.html