Have you ever felt the hassle of having to open Microsoft Excel just to convert a single CSV file to Excel (XLS or XLSX)? Or maybe you have to repeat that process many times every day for the data to keep updating.
Imagine this: with just a few command lines, you can convert CSV to XLS or XLSX in seconds, even for large files! No need to install additional software, no need to click repeatedly, and most importantly, the process can be fully automated.
In Windows 11, you can do CSV to Excel conversion with just a command line, using built-in tools like PowerShell.


Why Use the Command Line for CSV to Excel Conversion?
Managing data in CSV format is common in the modern world of work, especially in the fields of administration, finance, and data processing. However, when the data needs to be further processed or presented neatly in Excel format (.XLS or . XLSX), the conversion process is often a laborious job if done manually.
1. Super Fast Process Without Opening the App
One of the biggest advantages of using a command line is the speed of the process. You no longer need to open Microsoft Excel, load a CSV file, set the column format, and then resave it as an Excel file. All of these steps can be replaced with just one command line in the terminal.
2. Automation for Bulk Conversions
Command lines are not only fast, but they can also be automated. You can create a conversion script once, then run it multiple times, and even schedule it to run automatically every day or whenever a new file appears in a specific folder.
3. No additional costs required
Many users think they have to buy expensive software to perform data conversion efficiently. In fact, by using the built-in command line tools, you can run this process at no cost at all.
Tools Needed to Convert CSV to Excel via Command Line
Before you start converting CSV files to Excel (XLS/XLSX) via the command line in Windows 11, there are a few basic tools you need to set up.
1. Windows 11 (Latest Version Recommended)
For the best performance and maximum compatibility with tools like PowerShell or Command Prompt, make sure you’re using the latest version of Windows 11. The system is equipped with a variety of stability enhancements and modern features that strongly support command line-based execution of commands.
2. Command Prompt or PowerShell
The command line will not run without a terminal. In Windows, you have two main options that you can use to execute commands:
- Command Prompt (cmd.exe): A classic tool that’s been around for a long time on Windows. Suitable for basic and simple batch orders.
- PowerShell: More advanced than Command Prompt. It supports advanced scripting, complex data manipulation, as well as module integrations such as Import-Csv, Export-Excel, and so on.
For CSV to Excel conversion, PowerShell is highly recommended, as it supports a variety of third-party modules such as the very powerful ImportExcel.
3. Sample CSV file (e.g., data.csv)
To get this guide into practice right away, prepare a CSV file as an example. This file can contain simple data such as a list of names, email addresses, transactions, or products. You can create your own using Notepad, Excel, or download samples from the internet.
Examples of data.csv content:
Name,Email,Age
Ahmad,ahmad@example.com,30
Budi,budi@example.com,25
Citra,citra@example.com,28Make sure your CSV file:
- Using a comma delimiter (,), instead of a semicolon (;)
- Stored in an easily accessible directory, for example, in C:Data
Steps to Convert CSV to Excel (XLS/XLSX) via Command Line
In the Windows world, PowerShell is the Swiss Army knife for system automation. When it comes to CSV to Excel conversion, PowerShell offers an elegant solution through the ImportExcel module.
This ImportExcel module is specifically designed for manipulating Excel files directly from the command line, without the need for Microsoft Office installed. Its main advantage lies in its ability to handle large files with high efficiency, while still maintaining the original data format and structure.
Getting Started with the ImportExcel Module
Before you can take advantage of the power of this module, you need to install it first. The installation process is very simple:
Install-Module -Name ImportExcel -Force -Scope CurrentUserSome important things about this installation process:
- Parameter -Force ensures the installation runs without additional confirmation
- -Scope CurrentUser makes the module installed only for your current account
- The process requires an internet connection to download the package from the PowerShell Gallery
If you encounter an error about the execution policy, run it first:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUserCSV to Excel Conversion Magic Script
Once the module is successfully installed, you can immediately run the CSV to Excel file conversion script with the following syntax:
Import-Csv “C:\path\to\data.csv” | Export-Excel “C:\output\data.xlsx” -WorksheetName “Sheet1”Let’s dissect this script part by section:
- Import-Csv: Read a CSV file and convert it into a PowerShell object
- | (Pipeline): Sends data from one command to the next
- Export-Excel: Receive data and write it to an Excel file
- -WorksheetName: Specifies the name of the worksheet to be created
Advanced Variations for Complex Needs
The real strength of PowerShell lies in its flexibility. Here are some advanced modifications that you can implement:
1. Convert Multiple CSVs at Once
Get-ChildItem “C:\data\*.csv” | ForEach-Object {
$excelPath = $_.FullName -replace '\.csv$','.xlsx'
Import-Csv $_ | Export-Excel $excelPath
}2. Add Multiple Worksheets
$excel = New-Excel
Import-Csv “data1.csv” | Export-Excel -ExcelPackage $excel -WorksheetName “Sales”
Import-Csv “data2.csv” | Export-Excel -ExcelPackage $excel -WorksheetName “Inventory”
Close-ExcelPackage $excel -SaveAs “report.xlsx”3. With Automatic Formatting
Import-Csv “data.csv” | Export-Excel “output.xlsx” -AutoSize -BoldTopRow -FreezeTopRowTroubleshooting
While the process of converting a CSV file to Excel (XLSX) using PowerShell tends to be simple, in practice, you may encounter some technical issues, especially if you’re using the command line for the first time or working with large files. The following are some of the problems that often arise and how to deal with them effectively:
Unknown Modules
If you get an error message like The term ‘Export-Excel’ is not recognized, it signifies that PowerShell doesn’t recognize commands from the ImportExcel module. This issue usually occurs because the module is not installed correctly or PowerShell is running without administrator permission.
Solution:
- Make sure that you are running PowerShell as an Administrator. Right-click the PowerShell icon and select Run as administrator before running the Install-Module command.
- Check if the module is installed by running:
Get-Module -ListAvailable ImportExcel- If the module is not already present, repeat the installation process by:
Install-Module -Name ImportExcel -ForceError Encoding in CSV Files
Some CSV files, especially those from other systems or exports from third-party applications, may have encoding issues. If you notice strange characters or unreadable data after exporting to Excel, it is most likely an encoding issue.
Solution:
- Use the UTF8 Encoding parameter when importing CSV files. This will ensure that special characters such as accented letters or symbols are not damaged.
Import-Csv -Path “C:\path\data.csv” -Encoding UTF8 | Export-Excel “C:\output\data.xlsx”- Make sure the CSV file is saved in UTF-8 format. You can open the file with Notepad and save it again by selecting Save As > Encoding: UTF-8.
Process Feels Slow for Large Files
If you’re working with a large CSV file (e.g., more than 100MB), the conversion process may feel slow or even fail due to memory limitations. This is natural, especially if you’re using a low-spec computer or have many other apps open at the same time.
Solution:
- Consider splitting a CSV file into smaller parts using scripts or tools like split in WSL (Windows Subsystem for Linux).
- Run the conversions individually, then merge the results in Excel if needed.
- Make sure your computer has enough storage space and at least 8GB of RAM for handling large files.

