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

时间:2015-10-19 19:12:39   收藏:0   阅读:1570

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 

  

原文:http://www.cnblogs.com/ling-share/p/4892415.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!