excel - Powershell excel添加公式 - “公式包含无法识别的文本。”
问题描述
我正在使用 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 中?
提前致谢
解决方案
推荐阅读
- angular - 订阅函数外未定义的变量
- kotlin - 如何验证具有这些要求的字符串
- python - 如何显示两个消息框,每个消息框有两个条件?
- node.js - 批量喂食新商品时,我从 Walmart Canada Maketplace API 收到 404
- angular - 从对象中提取嵌套属性
- windows - 等于键突然意味着放大 Windows 中的所有应用程序
- apache-poi - 文件格式和扩展名
.xls 不匹配——apache-poi 4.1.2 - php - 此路由不支持 GET 方法。支持的方法:POST。- 用户注册错误
- python - django-admin-tools-stats :未找到“管理图表”的反向。'admin-charts' 不是有效的视图函数或模式名称
- python - EBPF 访问固定表