title: Speed up reading an Excel File in Powershell
body: <p>I wonder if there is any way to speed up reading an Excel file with powershell. Many would say I should stop using the <em>do until</em>, but the problem is I need it badly, because in my Excel sheet there can be 2 rows or 5000 rows. I understand that 5000 rows needs some time. But 2 rows shouldn't need 90sec+.</p>
  
  <pre><code>$Excel               = New-Object -ComObject Excel.Application
      $Excel.Visible       = $true
      $Excel.DisplayAlerts = $false
  $Path = EXCELFILEPATH
  $Workbook            = $Excel.Workbooks.open($Path)
  $Sheet1 = $Workbook.Worksheets.Item(test)
  
  $URows = @()
  Do {$URows += $Sheet1.Cells.Item($Row,1).Text; $row = $row + [int] 1} until (!$Sheet1.Cells.Item($Row,1).Text)
  $URows | foreach {
  $MyParms = @{};
  $SetParms = @{};
  </code></pre>
  
  <p>And i got this 30 times in the script too:    </p>
  
  <pre><code>If ($Sheet1.Cells.Item($Row,2).Text){$var1    = $Sheet1.Cells.Item($Row,2).Text
  $MyParms.Add("PAR1",$var1)
  $SetParms.Add("PAR1",$var1)}
                   }
  </code></pre>
  
  <p>I have the idea of running the $MyParms stuff contemporarily, but I have no idea how. Any suggestions?</p>
  
  <p>Or</p>
  
  <p>Increase the speed of reading, but I have no clue how to achieve that without destroying the "read until nothing is there".</p>
  
  <p>Or</p>
  
  <p>The speed is normal and I shouldn't complain.</p>