Closed dfinke closed 1 year ago
could not make it work.
TEXTJOIN
always failed with #NAME?
in cell.
Excel says, "unrecognized text in formula", but when I click formula bar and then any cell, it worked.
weird
BTW. -ArrayFormula
parameter can be replaced with leading @
in formula. See vlookup
. A leading @
acts as well as -ArrayFormula
parameter.
#Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$data = ConvertFrom-Csv @"
Fruit,Amount
Apples,50
Oranges,20
Bananas,60
Lemons,40
"@
$xl = Export-Excel -InputObject $data -Path $xlSourcefile -PassThru -AutoSize
Set-ExcelRange -Worksheet $xl.Sheet1 -Range D2 -BackgroundColor LightBlue -Value Apples
$rows = $xl.Sheet1.Dimension.Rows
Set-ExcelRange -Worksheet $xl.Sheet1 -Range E2 -Formula "@VLOOKUP(D2,A2:B${rows},2,FALSE)"
Set-ExcelRange -Worksheet $xl.Sheet1 -Range E3 -ArrayFormula -Formula "INDEX(B2:B${rows}, Match(D2,A2:A${rows},0))"
Set-ExcelRange -Worksheet $xl.Sheet1 -Range E4 -ArrayFormula -Formula "TEXTJOIN(`", `",TRUE,A2:A${rows})"
Close-ExcelPackage $xl -Show
I'm having the same problem when using IF() and Text.Merge()
Also problems with "" in the formula.... used backtic before each ". Didn't work.
-Formula "=IF('(1) Users'!L42="ja
";"ja
";"nee
")"
@RobMulder, to avoid backticks you can compose formulas using text formatter: '{0}{1}' -f arg1, arg2
@RobMulder I haven't tried it in context of the -Formula argument but in general you can escape quotes by using double quotes like so: "=IF('(1) Users'!L42=""ja"";""ja"";""nee"")"
@RobMulder I haven't tried it in context of the -Formula argument but in general you can escape quotes by using double quotes like so: "=IF('(1) Users'!L42=""ja"";""ja"";""nee"")"
I tried every combination of quotes and backtics. Nothing works.... I gave up;)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Discussed in https://github.com/dfinke/ImportExcel/discussions/1424