1 Star 0 Fork 0

lyra/python-Excel-Automation

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
xlrdTest.py 856 Bytes
一键复制 编辑 原始数据 按行查看 历史
import xlrd
print (xlrd.__file__)
#----------------------------------------------------------------------
def open_file(path):
"""
Open and read an Excel file
"""
book = xlrd.open_workbook(path)
# print number of sheets
print (book.nsheets)
# print sheet names
print (book.sheet_names())
# get the first worksheet
first_sheet = book.sheet_by_index(0)
# read a row
print (first_sheet.row_values(0))
# read a cell
cell = first_sheet.cell(0,0)
print (cell)
print (cell.value)
# read a row slice
print (first_sheet.row_slice(rowx=0,
start_colx=0,
end_colx=2))
#----------------------------------------------------------------------
if __name__ == "__main__":
path = "worksheet1.xlsx"
open_file(path)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/lyra_bj/python-Excel-Automation.git
git@gitee.com:lyra_bj/python-Excel-Automation.git
lyra_bj
python-Excel-Automation
python-Excel-Automation
master

搜索帮助