- ©«¤l
- 7
- ¥DÃD
- 2
- ºëµØ
- 0
- ¿n¤À
- 7
- ÂI¦W
- 0
- §@·~¨t²Î
- Win10
- ³nÅ骩¥»
- Win10
- ¾\ŪÅv
- 10
- µù¥U®É¶¡
- 2021-1-11
- ³Ì«áµn¿ý
- 2021-4-17
|
[µo°Ý] python xlwings °j°é³]©w½Ð±Ð
³z¹Lxlwings ¥i¥HŪ¨ú¨ì¨âÓsheetÄæ¦ì¼ÆÈ
¦pªGn¾ãÄæ¦ì³£¶]§¹¡A°j°é¤Wn«ç»ò³]p©O?(ex:B2->BMaxÄæ¦ì)
import xlwings as xw #¾É¤JXlwings module
import pandas as pd
app=xw.App(visible=True,add_book=False)
app.display_alerts=False #Ãö³¬Excel´£¥Ü®Ø
app.screen_updating=True #False 关闭«Ì¹õ§ó·s,¥i¥[§Ö§»ªº执¦æ³t«×,¬Ý¤£¨£sheet¤º®e
#Àɮצì¸m:filepath¡A¥´¶}ÀɮסA«O¦s¡AÃö³¬¡Aµ²§ôµ{¦¡
filepath=r'C:\Users\test.xlsx'
wb=app.books.open(filepath)
a=wb.sheets['sheet1'].range('B2').value
b=wb.sheets['sheet2'].range('B2').value
c=wb.sheets['sheet1'].range('P2').value
d=wb.sheets['sheet2'].range('P2').value
e=wb.sheets['sheet2'].range('Q2').value
f=wb.sheets['sheet2'].range('V2').value
if a==b and d=="Passed":
wb.sheets['sheet1'].range('P2').value='Passed'
wb.sheets['sheet1'].range('Q2').value=e
wb.sheets['sheet1'].range('V2').value=f
if a==b and d=="Failed":
wb.sheets['sheet1'].range('P2').value='Failed'
wb.sheets['sheet1'].range('Q2').value=e
wb.sheets['sheet1'].range('V2').value=f
if a==b and d=="Blocked":
wb.sheets['sheet1'].range('P2').value='Blocked'
wb.sheets['sheet1'].range('Q2').value=e
wb.sheets['sheet1'].range('V2').value=f
if a==b and d=="Exempted":
wb.sheets['sheet1'].range('P2').value='Exempted'
wb.sheets['sheet1'].range('Q2').value=e
wb.sheets['sheet1'].range('V2').value=f
print(a,b,c,d,e,f)
#wb.save()
#wb.close()
#app.quit() |
|