python使用xlrd读取excel表格方法
时间:2022-07-23 来源:未知 投稿:admin 点击:次
#例1: import xlrd workbook = xlrd.open_workbook(filename=r'd:\monitor.xlsx') table = workbook.sheet_by_index(0) names = workbook.sheet_names() row = table.nrows print(row) col = table.ncols print(col) num = table.row_len(0) print(num) table_list =table.row_values(rowx=0,start_colx=0,end_colx=None) print(table_list) table_list = table.col_values(colx=1,start_rowx=1,end_rowx=None) print(table_list) print(table.row(0)) value = table.cell_value(rowx=0,colx=1) print(value) #例2: workbook = xlrd.open_workbook(filename=r'd:\monitor.xlsx') table = workbook.sheet_by_index(0) rows = table.nrows cols = table.ncols for row in range(rows): for col in range(cols): value = table.cell_value(row,col) print('第{}行{}列数据为{}'.format(row,col,value))
如果您的问题仍未解决,还可以加入服务器在线技术交流QQ群:8017413寻求帮助。
相关内容