我不是100%确定此解决方案是否可以与DDE一起使用(文件是否正在写入磁盘的某个位置?)
我建议使用
xlrd(https://github.com/python-excel/xlrd)。我是通过pip亲自安装的。然后,简单地阅读A1:B3即可(删除文档):
from xlrd import open_workbookwb = 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))


