Add VLookup

This commit is contained in:
dfinke
2020-02-03 20:19:57 -05:00
parent 12fa49e314
commit e42f42fde9
2 changed files with 19 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
$xlfile = "$env:TEMP\test.xlsx"
Remove-Item $xlfile -ErrorAction SilentlyContinue
$data = ConvertFrom-Csv @"
Fruit,Amount
Apples,50
Oranges,20
Bananas,60
Lemons,40
"@
$xl = Export-Excel -InputObject $data -Path $xlfile -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)"
Close-ExcelPackage $xl -Show

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB