读取单元格
cell = sheet.cell(0,1).value # 直接定位
cell = sheet.cell_value(0,1) # 直接定位
cell = sheet.row(0)[1].value # 通过行索引定位
cell = sheet.col(1)[0].value # 通过列索引定位
获取单元格数据类型
cell_type = sheet.cell_type(0,1)
读取工作簿中所有工作表的名称
sheet_names = workbook.sheet_names()
读取整行、列的值
rows = sheet.row_values(0) # 整行的值
cols = sheet.col_values(1) # 整列的值
读取工作表的行、列数
nrow = sheet.nrows # 行数
ncol = sheet.ncols # 列数
2.1 xlutils 用法
导入xlutils库
import xlutils
打开一个工作簿
readbook = xlrd.open_workbook(‘ex.xls’)
workbook = xlutils.copy.copy(readbook)
获取工作表
sheet= workbook.get_sheet(0)
写入数据
sheet.write(1, 1, ‘data’)
添加工作表
workbook.add_sheet(‘Sheet2’,ce