使用Powershell插入复杂的Excel公式

这里是原创文章: 链接。

现在我的问题:

使用.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脚本后,我插入公式的单元格为空。

有任何想法吗?

我非常亲密,需要寻求帮助才能find答案!

 $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))" 

回答自己的问题并将答案标记为答案是否合乎道德?

编辑

Per @ 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))"