码迷,mamicode.com
首页 > 其他好文 > 详细

xlrd读取多个excel电子表数据

时间:2016-11-25 16:49:39      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:print   file   read   ack   filename   open   val   row   dex   

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电子表数据

标签:print   file   read   ack   filename   open   val   row   dex   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!