import xlrd
# 加载工作薄
path = r'C:\Users\Administrator\PycharmProjects\PythonAndOffice\PythonAndExcel\九九乘法表.xls'
workbook = xlrd.open_workbook(path,formatting_info=True)
# 加载表格
sheet = workbook.sheet_by_name('九九乘法表')
"""
sheet类,工作表中的表格
帮助查询:help(xlrd.sheet.Sheet)
注意:sheet类不能自己实例化,需要通过book类打开
"""
# 常用函数
# 1. cell(self, rowx, colx)
# 返回值:指定单元格(cell类) 单元格类名:'单元格内容'
exp_cell=sheet.cell(0,0)
print(type(exp_cell),exp_cell)
# 返回值:<class 'xlrd.sheet.Cell'> text:'1*1=2'
# 2. cell_type(self, rowx, colx)
# 返回值:制定单元格的数据类型
print(sheet.cell_type(0,0))
print(sheet.cell_type(0,
Python中xlrd库的类与方法介绍
最新推荐文章于 2024-06-10 22:18:41 发布