用python读取excel文件

吉吉:

haha总结一下常用的简单的用法

from xlrd import open_workbook
book=open_workbook(r'C:\Users\admin\Desktop\q.xlsx')
sheet=book.sheets_names()[0]#第一个工作表名称
sheet=data.sheet_by_name('Sheet1')#获得第一个工作表
sheet=book.sheets()[0]#获得第一个工作表
#获取总行数
nrows = table.nrows
#获取总列数
ncols = table.ncols
#工作表的数目
book.nsheets
sheet.cell(0,1)
sheet.row(0)
#读取第二列的内容,从第二行开始,并对其求和
sum(x.value for x in sheet.col(1,start_rowx=1))
sum(sheet.col_values(1,start_rowx=1))#同上

猜你喜欢

转载自blog.csdn.net/weixin_41503009/article/details/82530970