Read the Data inside a single Sheet inside .xlsx file using Power shell

john john 966 Reputation points
2023-01-23T22:59:35.3733333+00:00

I have an .xlsx which have the following:-

  1. Stored locally inside C drvie
  2. contains 5 sheets
  3. One sheet named as "Info", contain rows and columns without tables. first row represents the headers with filters, and the final row contain totals
  4. i need to read the data of the excel sheet named "Info" using Power shell

so can anyone advice on this please?

Thanks

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,552 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,595 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Castorix31 85,881 Reputation points
    2023-01-24T09:04:06.0866667+00:00

    You can find articles on Google, like :

    Read and Write Data to Excel File with PowerShell

    0 comments No comments

  2. Rich Matheisen 46,811 Reputation points
    2023-01-24T15:43:27.3366667+00:00

    Use the ImportExcel module: https://www.powershellgallery.com/packages/ImportExcel/7.8.4

    This will import the contents of the Excel files worksheet named "info" and place the date into the array "$f". Each item in $f will be a PSCustomObject.

    $f = Import-Excel -Path C:\junk\multisheet.xlsx -WorksheetName Info
    
    0 comments No comments

  3. Limitless Technology 44,401 Reputation points
    2023-01-25T09:16:34.9166667+00:00

    Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query.

    I have linked an article below that may help solve your issue. Here is what the article has to say:

    Use Import-Excel to read data directly from excel files. For instance, try the following to only receive the financial information for December:

    path with excel files

    (assuming you downloaded the sample data as instructed before)

    Set-Location -Path "$env:temp\excelsampledata"

    Import-Excel -Path .\financial.xlsx | Where-Object 'Month Number' -eq 12 | Out-GridView

    Import-Excel automatically reads data from the first worksheet. Use the parameter -WorksheetName to indicate the name of each worksheet in your file if it has more than one.

    REFERENCE: https://powershell.one/tricks/parsing/excel

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    0 comments No comments

  4. Limitless Technology 44,401 Reputation points
    2023-01-25T09:16:51.9033333+00:00

    Double post

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.