import os
import xlwings as xw
# python获取文件下文件并将其写入excel一列单元格
app = xw.App()
wb = app.books.add()
sht = wb.sheets['sheet1']
filename = os.listdir('c:\\')
i = 0
ai=['a1','a2','a3','a4','a5','a6','a7','a8','a9','a10','a11','a12','a13','a14','a15','a16','a17','a18','a19','a20']
# print(ai[0])
while i < len(filename):
print(filename[i])
sht.range(ai[i]).value = filename[i]
i = i + 1
wb.save('d:\\demo1.xlsx')
app.quit()
python获取文件下文件并将其写入excel一列单元格(笨法)
最新推荐文章于 2023-05-13 17:17:34 发布