python 讀取excel表中sheetname的兩種方法

1. python

import xlrd

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

2.app

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 
相關文章
相關標籤/搜索