如何在xlwings上偏移和插入

时间:2019-04-24 11:45:17

标签: xlwings

我想遍历几个xlsm文件,并将range(“ A2:P2”)复制到一个工作簿(ProjectSummary.xlsx)。

我正在寻找偏移量代码,以便每个xlsm文件都给我一行。 那就是我到目前为止所做的:

from os import listdir
from os.path import isfile, join
import xlwings as xw

path = "C:\Projects\SuperProject\BorotNisayon"
onlyxlsmFiles = [f for f in listdir(path) if isfile(join(path, f)) and f.endswith(".xlsm")]
wb = xw.Book("C:\Projects\SuperProject\BorotNisayon\ProjectSummary.xlsx")
sht = wb.sheets[0] 



# Iterates through excel workbooks in the directroy 
for excel in excel_list:
    
    # Opens an excel from the directory
    wb2 = xw.Book(r'C:\Projects\SuperProject\BorotNisayon'.format(excel))
    # Grabs the needed value
    copy_value = sheets['Log'].range('A2:P2')
    # Addes the copy_value to the specified cell
    copy_value=sht.value
    #Closes workbook
    wb2.close()
excel =+1 
print("Script complete")
print (onlyxlsmFiles)`

0 个答案:

没有答案
相关问题