打开Excel文件,以list形式返回第一列的值
import xlrd
def newDbFind():
spinfo = xlrd.open_workbook('dispose.xlsx')
sh = spinfo.sheet_by_index(0)#返回第几页的对象
spcodeList = sh.col_values(0)
读取Excel文件
#coding:utf-8
import xlrd
goods = xlrd.open_workbook('goods_test.xlsx')#打开文件
sh = goods.sheet_by_index(3)#返回第几页的对象
for rx in range(sh.nrows):
print sh.row(rx) #返回每一行的数据
for cl in range(sh.ncols):
print sh.col(cl) #返回每一列的数据
print sh.col(2)
print sh.col_values(2)
print 'Goods name:',goods.sheet_names()
print sh.cell(2.2).ctypeprint sh.name,sh.nrows,sh.ncols#返回对象页的名称,行数和列数
print "Cell D30 is",sh.cell_value(rowx=20,colx=3)#返回特定数值
print 'The number of goodssheets is:', goods.nsheets#返回有几页