python读取excel数据

1.打开excel文件

data = xlrd.open_workbook()

2.获取工作表

table = data.sheets()[0]

table = data.sheet_by_index(0)

table = data.sheet_by_name(u'sheet_name')

3.获取工作表整行和整列值(数组)

table.row_values(i)

table.col_values(i)

4.获取行数和列数

nrows=table.nrows

ncols=table.ncols

5.循环行列表数据

for i in range(nrows):

         print table.row_values(i)

6.获取单元格数据

cell_A1=table.cell(0,0).value

cell_A1=table.row(0)[0].value

 

posted @ 2017-08-25 16:08  轻幻  阅读(224)  评论(0编辑  收藏  举报