Skip to content

Commit

Permalink
only lookup cells once
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardmiller-mesirow committed May 20, 2024
1 parent cfb556e commit 71ef167
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Public/Import-Excel.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Import-Excel {
function Import-Excel {
[CmdLetBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSPossibleIncorrectUsageOfAssignmentOperator', '', Justification = 'Intentional')]
Expand Down Expand Up @@ -161,7 +161,10 @@
#using Hash tables: "we've seen it" is all we need, no need to worry about "seen it before" / "Seen it many times".
$colHash = @{ }
$rowHash = @{ }
foreach ($cell in $sheet.Cells[$range]) {

$cells = $sheet.Cells[$range]

foreach ($cell in $cells) {
if ($null -ne $cell.Value ) { $colHash[$cell.Start.Column] = 1; $rowHash[$cell.Start.row] = 1 }
}
$rows = ( $StartRow..$EndRow ).Where( { $rowHash[$_] })
Expand Down

0 comments on commit 71ef167

Please sign in to comment.