-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexcel-Practice.ps1
More file actions
79 lines (51 loc) · 1.66 KB
/
Copy pathexcel-Practice.ps1
File metadata and controls
79 lines (51 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#$path = "$env:userprofile\documents\personaldocs\Work Authorizations.xlsx"
<#Do {
$Column = $Worksheet.Cells.Item($Row, $Col).Value().trim()
$ArrHeaders += $Column -replace " ", ""
$intCol++
}While ($Worksheet.Cells.Item(1,$Col).Value() -ne $null) #>
function Import-ExcelFile {
param(
[parameter()]
$file = "$env:userprofile\documents\personaldocs\Work Authorizations.xlsx",
[prameter()]
$page = 'Sheet1'
)
$excel = New-Object -ComObject Excel.Application
try{
$workBook = $excel.Workbooks.Open($path)
}catch{
Write-host "Unable to open excelsheet"
Write-host $error[0].exception.Message
exit
}
$workSheet = $workBook.worksheets | Where-Object {$_.Name -eq $page}
return $worksheet
}
Function Get-Value {
param(
[parameter()]
[System.Collections.ArrayList]$contractNumbers
)
$contractNums = $contractNum.split("-")
$loop = $true
$numberOfResults = 1
$firstRow = $found.row
$foundArr = new-object System.Collections.ArrayList
$found = $worksheet.Cells.Find($contractNums[0])
while($loop -eq $true){
$foundarr.Add($found)
$found = $worksheet.Cells.FindNext($found)
$currentRow = $found.row
if ($currentRow -eq $firstRow){
$loop = $false
}else{
$numberOfResults++
}
}
forEach ($item in $foundarr){
if ($workSheet.cells.item($item.row,10).text -eq "001"){
$found = $item
}
}
}