PowerShell: How to Convert XLSX to CSV (With Example)

You can use the following basic syntax in PowerShell to convert a XLSX file to a CSV file:

Import-Excel -Path "c:\my\data.xlsx" | Export-Csv -Path "c:\my\data.csv" -NoTypeInformation

This particular example will convert the XLSX file named data.xlsx to a CSV file named data.csv.

Note that this example assumes you have the ImportExcel module installed on PowerShell.

If you do not already have this module installed, you can use the following steps to install it:

1. Open your PowerShell console as an administrator.

2. Type the following: Install-Module ImportExcel

Once you have this module installed, you will be able to easily convert XLSX files to CSV files.

The following example shows how to do so in practice.

Example: How to Convert XLSX File to CSV File Using PowerShell

Suppose we have an XLSX file named basketball_data.xlsx saved in the following location:

  • c:\users\bobbi\basketball_data.xlsx

Here is what this file looks like:

The file contains information about points, assists and rebounds for various basketball players on some team.

Suppose that we would like to convert this XLSX file to a CSV file and save it in the same directory.

We can use the following syntax to do so:

Import-Excel -Path "c:\users\bobbi\basketball_data.xlsx" | Export-Csv -Path "c:\users\bobbi\basketball_data.csv" -NoTypeInformation 

The following screenshot shows how to use this syntax in practice:

PowerShell convert XLSX to CSV

If we’d like, we can navigate to the location where this CSV file was created on our computer and open it using a text editor:

We can see that the CSV file contains the exact same information as the XLSX file but it’s formatted using comma separated values.

Note that we used -NoTypeInformation to tell PowerShell not to include the type information header in the exported file.

Here is what our file would look like if we didn’t include -NoTypeInformation in the command:

Notice that the first line of the CSV file contains #TYPE information.

In most cases we don’t want to include this information in the exported file.

Related Tutorials

The following tutorials explain how to perform other common tasks in PowerShell:

PowerShell: How to Delete All Files with Specific Extension
PowerShell: How to Rename File Extension of Multiple Files
PowerShell: How to Replace Every Occurrence of String in File

Leave a Reply