[英]Insert complicated Excel formula using Powershell
這是原始文章: 鏈接。
現在我的問題:
使用 .formula,我可以走得很遠,但我有一個非常復雜的公式,它不想工作。
在 Excel 中工作的代碼:
=IF(ISBLANK(G2),"",VLOOKUP("*"&LEFT(G2,9)&"*",'\\compname\path\to\excel\[ramdata.xlsx]20151009'!A:B,2,FALSE))
在 Powershell 中不起作用的代碼:
$ws.Cells.Item($intRow,9).Formula = '=VLOOKUP("*"$([char]38)LEFT(G$intRow,5)$([char]38)"*",'\\compname\path\to\excel\[ramdata.xlsx]20151009'!A:B,2,FALSE)'
運行 powershell 腳本后,插入公式的單元格為空白。
有任何想法嗎?
我是如此接近,需要尋求幫助才能找到答案!
$ws.Cells.Item($intRow,9).Formula = "=IF(ISBLANK(G$intRowMem),$([char]34)$([char]34),VLOOKUP($([char]34)*$([char]34)&LEFT(G$intRowMem,5)&$([char]34)*$([char]34),'\\compname\path\to\excel\[ramdata.xlsx]20151009'!A:B,2,FALSE))"
回答您自己的問題並將您的答案標記為答案是否合乎道德?
編輯
根據@TheMadTechnician,這也可以解決為:
$ws.Cells.Item($intRow,9).Formula = "=IF(ISBLANK(G$intRowMem),`"`",VLOOKUP(`"*`"&LEFT(G$intRowMem,5)&`"*`",'\\compname\path\to\excel\[ramdata.xlsx]20151009'!A:B,2,FALSE))"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.