only get cell value once

This commit is contained in:
Edward Miller
2024-05-17 22:05:49 -05:00
parent 74cbca8b2f
commit 84684ae27b

View File

@@ -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 {