Skip to content

Commit

Permalink
only get cell value once
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardmiller-mesirow committed May 18, 2024
1 parent 74cbca8 commit 84684ae
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Public/Import-Excel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,15 @@
$NewRow = [Ordered]@{ }
if ($TextColRegEx) {
foreach ($P in $PropertyNames) {
$cell = $sheet.Cells[$R, $P.Column]
$MatchTest = $TextColRegEx.Match($P.value)
if ($MatchTest.groups.name -eq "astext") {
$NewRow[$P.Value] = $sheet.Cells[$R, $P.Column].Text
$NewRow[$P.Value] = $cell.Text
}
elseif ($MatchTest.groups.name -eq "asdate" -and $sheet.Cells[$R, $P.Column].Value -is [System.ValueType]) {
$NewRow[$P.Value] = [datetime]::FromOADate(($sheet.Cells[$R, $P.Column].Value))
elseif ($MatchTest.groups.name -eq "asdate" -and $cell.Value -is [System.ValueType]) {
$NewRow[$P.Value] = [datetime]::FromOADate($cell.Value)
}
else { $NewRow[$P.Value] = $sheet.Cells[$R, $P.Column].Value }
else { $NewRow[$P.Value] = $cell.Value }
}
}
else {
Expand Down

0 comments on commit 84684ae

Please sign in to comment.