您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

python库或代码以读取已打开的Excel文件

python库或代码以读取已打开的Excel文件

我不是100%确定此解决方案是否可以与DDE一起使用(文件是否正在写入磁盘的某个位置?)

我建议使用xlrdhttps://github.com/python-excel/xlrd)。我是通过pip亲自安装的。然后,简单地阅读A1:B3即可(删除文档):

from xlrd import open_workbook

wb = open_workbook('spreadsheet.xlsx')
for s in wb.sheets():
     print('Sheet:',s.name) # you can check for the sheet name here if you want
     for row in range(2): #the first 2 rows (A and B) (use s.nrows for all)
         values = []
         for col in range(3): #the first 3 columns (use s.ncols for all)
            values.append(str(s.cell(row,col).value))
         print(','.join(values))
python 2022/1/1 18:28:58 有182人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶