Excel 2007-2010二进制工作簿(XLSB)分析器
pyxlsb的Python项目详细描述
pyxlsb是用于 Python。图书馆目前极为有限,但功能强大 足够提取基本数据了。
安装
pip install pyxlsb
用法
模块公开一个open_workbook(name)方法(类似于xlrd 和openpyxl),用于打开xlsb文件。工作簿对象表示 文件被返回。
frompyxlsbimportopen_workbookwithopen_workbook('Book1.xlsb')aswb:# Do stuff with wb
工作簿对象公开用于检索 工作表实例。
# Using the sheet index (1-based)withwb.get_sheet(1)assheet:# Do stuff with sheet# Using the sheet namewithwb.get_sheet('Sheet1')assheet:# Do stuff with sheet
提示:包含工作表名称的sheets属性在上可用 工作簿实例。
rows()方法将发出一个迭代器来读取工作表 排。
# You can use .rows(sparse=True) to skip empty rowsforrowinsheet.rows():print(row)# [Cell(r=0, c=0, v='TEXT'), Cell(r=0, c=1, v=42.1337)]
请注意日期将显示为浮动。你必须使用 ^来自pyxlsb模块的{tt6}$方法来转换它们 进入datetime实例。
frompyxlsbimportconvert_dateprint(convert_date(41235.45578))# datetime.datetime(2012, 11, 22, 10, 56, 19)