Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell excel添加公式-“;公式包含无法识别的文本。”;_Excel_Powershell - Fatal编程技术网

Powershell excel添加公式-“;公式包含无法识别的文本。”;

Powershell excel添加公式-“;公式包含无法识别的文本。”;,excel,powershell,Excel,Powershell,我正在使用powershell处理excel工作表,其中将添加一些公式 所有这些都可以工作,但在excel中它们显示为#NAME? 详细信息:公式包含无法识别的文本 $FilePath = "C:\Temp 1\Recipes_light.xlsx" $objexcel = New-Object -ComObject Excel.Application $objexcel.Visible = $true $objexcel.DisplayAlerts = $False $wb = $objexc

我正在使用powershell处理excel工作表,其中将添加一些公式

所有这些都可以工作,但在excel中它们显示为
#NAME?

详细信息:公式包含无法识别的文本

$FilePath = "C:\Temp 1\Recipes_light.xlsx"
$objexcel = New-Object -ComObject Excel.Application
$objexcel.Visible = $true
$objexcel.DisplayAlerts = $False
$wb = $objexcel.WorkBooks.Open($FilePath)  
$ws = $wb.Worksheets.Item(1)


$rows = $ws.UsedRange.Rows.Count

# add column
$range = $ws.Range("E:E").EntireColumn
$range.Insert($xlShiftToRight)

# header 
$ws.cells.Item(1,5).Value = "SAP Vertriebstext"

# autofit whole sheet
[void]$ws.cells.entireColumn.Autofit()

# vlookup in excel
$vl = "=SVERWEIS(D2,[GesamtlisteProdukte_Deutschland.xlsx]RMQ!`$C:`$J,8,0)"

$ws.range("E2:E$rows").formula = $vl
如果我点击公式并按下“回车”键,它就会工作。所以所有的细胞都需要被触摸

有没有安全的方法通过powershell将vlookup公式添加到excel中


提前感谢您在PowerShell中使用Excel公式,您始终使用英语语法:$vl=“=VLOOKUP(D2,[GesamtlisteProdukte_Deutschland.xlsx]RMQ!
$C:
$J,8,0)”就是这样!太好了…谢谢f6a4指出这一点。