版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_40603236/article/details/79596487
#coding:utf-8
import xlrd
import os
class Readexcel(object):
def __init__(self):
self.path=os.path.abspath('.')+'/date/'
def read_excel(self,name,sheet_name):
full_path=self.path+name
#打开excel
try:
book=xlrd.open_workbook(full_path)
print ('excel is open')
except Exception as e:
print (e)
#获取sheel
sheel=book.sheet_by_name(sheet_name)
#获取行数
nrows=sheel.nrows
#获取列数
ncols=sheel.ncols
#获取第一列第三行的值
date=sheel.cell(0,2).value
return (nrows,date,date)
readexcel=Readexcel()
readexcel.read_excel(name,sheet_name)