mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Compare commits
3 Commits
copilot/fi
...
566a092736
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
566a092736 | ||
|
|
cfb556ea77 | ||
|
|
84684ae27b |
@@ -217,21 +217,26 @@
|
|||||||
#Disabled write-verbose for speed
|
#Disabled write-verbose for speed
|
||||||
# Write-Verbose "Import row '$R'"
|
# Write-Verbose "Import row '$R'"
|
||||||
$NewRow = [Ordered]@{ }
|
$NewRow = [Ordered]@{ }
|
||||||
|
|
||||||
|
# Get the entire row first
|
||||||
|
$row = $sheet.Cells[$R, 1, $R, $sheet.Dimension.End.Column]
|
||||||
|
|
||||||
if ($TextColRegEx) {
|
if ($TextColRegEx) {
|
||||||
foreach ($P in $PropertyNames) {
|
foreach ($P in $PropertyNames) {
|
||||||
|
$cell = $row[$R, $P.Column]
|
||||||
$MatchTest = $TextColRegEx.Match($P.value)
|
$MatchTest = $TextColRegEx.Match($P.value)
|
||||||
if ($MatchTest.groups.name -eq "astext") {
|
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]) {
|
elseif ($MatchTest.groups.name -eq "asdate" -and $cell.Value -is [System.ValueType]) {
|
||||||
$NewRow[$P.Value] = [datetime]::FromOADate(($sheet.Cells[$R, $P.Column].Value))
|
$NewRow[$P.Value] = [datetime]::FromOADate($cell.Value)
|
||||||
}
|
}
|
||||||
else { $NewRow[$P.Value] = $sheet.Cells[$R, $P.Column].Value }
|
else { $NewRow[$P.Value] = $cell.Value }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach ($P in $PropertyNames) {
|
foreach ($P in $PropertyNames) {
|
||||||
$NewRow[$P.Value] = $sheet.Cells[$R, $P.Column].Value
|
$NewRow[$P.Value] = $row[$R, $P.Column].Value
|
||||||
# Write-Verbose "Import cell '$($Worksheet.Cells[$R, $P.Column].Address)' with property name '$($p.Value)' and value '$($Worksheet.Cells[$R, $P.Column].Value)'."
|
# Write-Verbose "Import cell '$($Worksheet.Cells[$R, $P.Column].Address)' with property name '$($p.Value)' and value '$($Worksheet.Cells[$R, $P.Column].Value)'."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user