首页 > 其他 > 详细

xlrd读取多个excel电子表数据

时间:2016-11-25 16:47:24      阅读:245      评论:0      收藏:0      [点我收藏+]
import sys
import xlrd
import traceback

def ReadData(FileName):

  try:
      workBook = xlrd.open_workbook(FileName) 
      sheetsList = workBook.sheet_names() 
      sheetNum = len(sheetsList)

      for i in range(sheetNum):
          readName = sheetsList[i]
         #para = [‘sheet%s‘ %i]
          sheet = workBook.sheet_by_index(i)	
          print(readName+‘:\n‘) 
          for i in range(sheet.nrows):
               rows = sheet.row_values(i)
               print(rows)
  except:
      traceback.print_exc() 

if __name__ == ‘__main__‘ : 

      ReadData(‘demo1.xlsx‘)	

  

xlrd读取多个excel电子表数据

原文:http://www.cnblogs.com/luoye00/p/6101943.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!