首页 > 代码库 > xlrd读取多个excel电子表数据

xlrd读取多个excel电子表数据

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