1. 程式人生 > >xlwings遍歷多個excel工作簿獲取指定的單元格資料

xlwings遍歷多個excel工作簿獲取指定的單元格資料

# -*- coding: utf-8 -*-

import glob

import xlwings as xw
x=glob.glob(r'D:\Python實踐\測試報告\*.xls*')
if len(x) :
    print(x)
    for y in x:
        wb=xw.Book(y)
        sht=wb.sheets[0]
        print(sht.range('b2').value,'--->',sht.range('c2').value)
        wb.app.quit()
else:

    print('no related files')