Home Forums Programming Powershell Powershell and Excel and SQL Server RE: Powershell and Excel and SQL Server

  • I'm doing this in a loop: it's taking about .5 seconds/row to access these cells, + another .5 seconds for processing.

    $nId = $UserWorksheet.Cells.Item($intRow, 1)

    $cE_Description= $UserWorksheet.Cells.Item($intRow, 2)

    $cF_Description = $UserWorksheet.Cells.Item($intRow, 3)

    $nParent_Id= $UserWorksheet.Cells.Item($intRow, 4)

    $cOther= $UserWorksheet.Cells.Item($intRow, 5)

    $cActive = $UserWorksheet.Cells.Item($intRow, 6)

    $nExclusive= $UserWorksheet.Cells.Item($intRow, 7)

    $cDefaultChecked = $UserWorksheet.Cells.Item($intRow, 8)

    Not great performance on 100 rows, downright painful when the number of rows starts to get up there.

    So what I was hoping for is a way to get the entire sheet's data read into an array -- or an object -- all at once, I'm thinking that should speed up processing.