---
title: "PowerShell and Excel: Harness the Power of ImportExcel"
description: "Master the ImportExcel module to use PowerShell and Excel together. Create charts, pivot tables, and leverage Excel's powerful features."
canonical: "https://adamtheautomator.com/powershell-excel/"
---

# PowerShell and Excel: Harness the Power of ImportExcel

> Master the ImportExcel module to use PowerShell and Excel together. Create charts, pivot tables, and leverage Excel's powerful features.

Source: https://adamtheautomator.com/powershell-excel/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![PowerShell and Excel: Harness the Power of ImportExcel](https://adamtheautomator.com/wp-content/uploads/2019/12/accounting-1928237_1280.png)

# PowerShell and Excel: Harness the Power of ImportExcel

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)22 December 20195 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Microsoft Excel](/tag/microsoft-excel/)[PowerShell](/tag/powershell/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Installing the ImportExcel Module](#installing-the-importexcel-module)
*   [Using PowerShell and Excel to Export to a Worksheet](#using-powershell-to-export-to-an-excel-worksheet)
*   [Using PowerShell to Import to Excel](#using-powershell-to-import-to-excel)
*   [Using PowerShell to Get (and Set) Excel Cell Values](#using-powershell-to-get-and-set-excel-cell-values)
*   [Converting Worksheets to CSV Files with PowerShell and Excel](#converting-excel-to-csv-files-with-powershell)
*   [Converting Multiple Worksheets](#converting-multiple-worksheets)
*   [Conclusion](#conclusion)

Microsoft Excel is one of those ubiquitous tools most of us can’t escape even if we tried. Many IT professionals use Excel as a little database storing tons of data in various automation routines. What’s the best scenario for automation and Excel? PowerShell and Excel!

Excel spreadsheets have always been notoriously hard to script and automate. Unlike its less-featured (and simpler) CSV file counterpart, Excel workbooks aren’t just simple text files. Excel workbooks required PowerShell to manipulate complicated [Component Object Model (COM) objects](https://docs.microsoft.com/en-us/windows/win32/com/the-component-object-model) thus you had to have Excel installed. Not anymore.

Thankfully, an astute PowerShell community member, [Doug Finke](https://twitter.com/dfinke), created a PowerShell module called [ImportExcel](https://github.com/dfinke/ImportExcel) for us mere mortals. The ImportExcel module abstracts away all of that complexity. It makes it possible to easily [manage Excel workbooks and get down to PowerShell](https://adamtheautomator.com/powershell-scheduled-task/) scripting!

In this article, let’s explore what you can do with PowerShell and Excel using the ImportExcel module and a few popular use cases.

If your Excel automation is moving from scripted exports into recurring spreadsheet analysis, compare [PopAi AI Sheets for spreadsheet editing, report generation, and document data extraction](https://sheets.popai.pro/?sharedid=&irpid=1454808&irgwc=1&afsrc=1) before choosing a paid AI spreadsheet tool.

## Prerequisites

When running the ImportExcel module on a Windows system, no separate dependencies are necessary. However, if you’re working on macOS, you will need to install the _mono-libgdiplus_ package using `brew install mono-libgdiplus`. All examples in this article will be built using macOS but all examples should work cross-platform.

> _If you’re using macOS, be sure to restart your PowerShell session before continuing._

## Installing the ImportExcel Module

Start by downloading and installing the module via the PowerShell Gallery by running `Install-Module ImportExcel -Scope CurrentUser`. After a few moments, you’ll be good to go.

## Using PowerShell and Excel to Export to a Worksheet

You may be familiar with the standard PowerShell cmdlets `Export-Csv` and [`Import-Csv`](https://adamtheautomator.com/import-csv/ "Import-Csv"). These cmdlets allow you to read and export PowerShell objects to CSV files. Unfortunately, there’s no `Export-Excel` and `Import-Excel` cmdlets. But using the ImportExcel module, you can build your own functionality.

Related: [Managing CSV Files in PowerShell with Import-Csv](https://adamtheautomator.com/import-csv/)

One of the most common requests a sysadmin has is exporting PowerShell objects to an Excel worksheet. Using the `Export-Excel` cmdlet in the ImportExcel module, you can easily make it happen.

For example, perhaps you need to find some processes running on your local computer and get them into an Excel workbook.

> _The `Export-Excel` cmdlet accepts any object exactly the way [`Export-Csv`](https://adamtheautomator.com/export-csv/ "Export-Csv") does. You can pipe any kind of object to this cmdlet._

To find processes running on a system with PowerShell, use the [`Get-Process`](https://adamtheautomator.com/powershell-get-process/ "Get-Process") cmdlet which returns each running process and various information about each process. To export that information to Excel, use the `Export-Excel` cmdlet providing the file path to the Excel workbook that will be created. You can see an example of the command and screenshot of the Excel file generated below.

```powershell
Get-Process | Export-Excel -Path './processes.xlsx'
```

![Worksheet created with PowerShell and Excel](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-95.png)

Worksheet created with PowerShell and Excel

Congrats! You’ve now exported all the information just like `Export-Csv` but, unlike `Export-Csv`, we can make this data a lot fancier. Let’s make sure the worksheet name is called **Processes**, the data is in a [table](https://support.microsoft.com/en-us/office/overview-of-excel-tables-7ab0bb7d-3a9e-4b56-a3c9-6c94334e492c?ui=en-us&rs=en-us&ad=us) and rows are auto-sized.

By using the `AutoSize` switch parameter to autosize all rows, `TableName` to specify the name of the table that will include all the data and the `WorksheetName` parameter name of _Processes_, you can see in the screenshot below what can be built.

```powershell
Get-Process | Export-Excel -Path './processes.xlsx' -AutoSize -TableName Processes -WorksheetName Proccesses
```

![Autosize Switch Parameter Result](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-96-1024x161.png)

Autosize Switch Parameter Result

> _The `Export-Excel` cmdlet has a ton of parameters you can use to create Excel workbooks of all kinds. For a full rundown on everything `Export-Excel` can do, run `[Get-Help](https://adamtheautomator.com/powershell-get-help/ "Get-Help") Export-Excel`._

## Using PowerShell to Import to Excel

So you’ve exported some information to a file called _processes.xlsx_ in the previous section. Perhaps now you need to move this file to another computer and import/read this information with PowerShell and Excel. No problem. You have `Import-Excel` at your disposal.

At its most basic usage, you only need to provide the path to the Excel document/workbook using the `Path` parameter as shown below. You’ll see that it reads the first worksheet, in this case, the _Processes_ worksheet, and returns PowerShell objects.

```powershell
Import-Excel -Path './processes.xlsx'
```

![Path Parameter](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-97.png)

Path Parameter

Maybe you have multiple worksheets in an Excel workbook? You can read a particular worksheet using the `WorksheetName` parameter.

```powershell
Import-Excel -Path './processes.xlsx' -WorkSheetname SecondWorksheet
```

Do you need to only read certain columns from the Excel worksheet? Use the `HeaderName` parameter to specify only those parameters you’d like to read.

```powershell
Import-Excel -Path './processes.xlsx' -WorkSheetname Processes -HeaderName 'CPU','Handle'
```

> _The `Import-Excel` cmdlet has other parameters you can use to read Excel workbooks of all kinds. For a full rundown on everything `Import-Excel` can do, run `Get-Help Import-Excel`._

## Using PowerShell to Get (and Set) Excel Cell Values

You now know how to read an entire worksheet with PowerShell and Excel but what if you only need a single cell value? You technically _could_ use `Import-Excel` and filter out the value you need with [`Where-Object`](https://adamtheautomator.com/powershell-where-object/ "Where-Object") but that wouldn’t be too efficient.

Instead, using the `Open-ExcelPackage` cmdlet, you can “convert” an Excel workbook into a PowerShell object which can then be read and manipulated. To find a cell value, first, open up the Excel workbook to bring it into memory.

```powershell
$excel = Open-ExcelPackage -Path './processes.xlsx'
```

> _The `Open-ExcelPackage` is similar to using `New-Object -comobject excel.application` if working directly with COM objects._

Next, pick the worksheet inside of the workbook.

```powershell
$worksheet = $excel.Workbook.Worksheets['Processes']
```

> _This process is similar to the COM object way of opening workbooks with `excel.workbooks.open`._

Once you have the worksheet assigned to a variable, you can now drill down to individual rows, columns, and cells. Perhaps you need to find all cell values in the A1 row. You simply need to reference the `Cells` property providing an index of A1 as shown below.

```powershell
$worksheet.Cells['A1'].Value
```

> _You can also change the value of cells in a worksheet by assigning a different value eg. `$worksheet.Cells['A1'] = 'differentvalue'`_

Once in memory, it’s important to release the Excel package using the `Close-ExcelPackage` cmdlet.

```powershell
Close-ExcelPackage $excel
```

## Converting Worksheets to CSV Files with PowerShell and Excel

Once you have the contents of an Excel worksheet represented via PowerShell objects, “converting” Excel worksheets to CSV simply requires sending those objects to the `Export-Csv` cmdlet.

Related:[Export-Csv: Converting Objects to CSV Files](https://adamtheautomator.com/export-csv/)

Using the _processes.xlsx_ workbook created earlier, read the first worksheet which gets all of the data into PowerShell objects, and then export those objects to CSV using the command below.

```powershell
Import-Excel './processes.xlsx' | Export-Csv -Path './processes.csv' -NoTypeInformation
```

If you now open up the resulting CSV file, you’ll see the same data inside of the _Processes_ worksheet (in this example).

### Converting Multiple Worksheets

If you have an Excel workbook with multiple worksheets, you can also create a CSV file for each worksheet. To do so, you can find all the sheets in a workbook using the `Get-ExcelSheetInfo` cmdlet. Once you have the worksheet names, you can then pass those names to the `WorksheetName` parameter and also use the sheet name as the name of the CSV file.

Below you can the example code needed using PowerShell and Excel.

```powershell
## find each sheet in the workbook
$sheets = (Get-ExcelSheetInfo -Path './processes.xlsx').Name
## read each sheet and create a CSV file with the same name
foreach ($sheet in $sheets) {
	Import-Excel -WorksheetName $sheet -Path './processes.xlsx' | Export-Csv "./$sheet.csv" -NoTypeInformation
}
```

## Conclusion

Using PowerShell and Excel, you can import, export, and manage data in Excel workbooks exactly like you would CSVs without having to install Excel!

In this article, you learned the basics of reading and writing data in an Excel workbook but this just scratches the surface. Using PowerShell and the ImportExcel module, you can create charts, pivot tables, and leverage other powerful features of Excel!

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-excel%2F&text=PowerShell%20and%20Excel%3A%20Harness%20the%20Power%20of%20ImportExcel)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-excel%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-excel%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2021/03/What-is-a-CSV-File-How-to-Create-Open-and-Work-with-Them.jpg)

### [What is a CSV File, How to Create, Open and Work with Them](/csv-file/)

Learn how CSV files came to be, how they’re structured and how to work with them in PowerShell and Microsoft Excel in this guide.

![](https://adamtheautomator.com/wp-content/uploads/2026/06/26995-troubleshoot-dns-issues-powershell-codex.webp)

### [Troubleshoot DNS Issues with PowerShell](/troubleshoot-dns-issues-powershell/)

Troubleshoot DNS issues with PowerShell by testing name resolution, DNS client settings, cache entries, and network connectivity in a repeatable workflow.

![](https://adamtheautomator.com/wp-content/uploads/2025/10/image_2025-10-24_095322075.png)

### [Migrating from PowerShell 6 to 7.5: Breaking Changes/New Features](/migrating-powershell-6-to-7-5/)

Migrate from PowerShell Core 6 to 7.5: breaking changes, features, and testing tips.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
