How to convert CSV to Excel .xlsx from the right-click context menu in Windows

Jonáš Jančařík
2 min readJan 14, 2020

This setup uses csv2xlsx, a command-line tool by Armin Hanisch (twitter.com/DerLinkshaender).

  1. Download the executable from https://gitlab.com/DerLinkshaender/csv2xlsx/blob/master/csv2xlsx_amd64.exe
  2. Rename the file to csv2xlsx.exe and place it in your user folder (i.e. C:\Users\<yourusername>)
  3. Open PowerShell with admin priviledges (right-click the Start button, select Windows Powershell (Admin))
  4. Run the following command:
reg add HKEY_CURRENT_USER\Software\Classes\Excel.CSV\shell\"Convert to Excel (.xlsx)"\command /ve /t REG_EXPAND_SZ /d '%USERPROFILE%\csv2xlsx.exe -infile \"%1\" -colsep , -silent -fontname Calibri -sheet Sheet1'

You should now see a new context menu item when you right-click a CSV file:

The new context menu item

The converted file will have the same name as the original file and will appear in the same folder, just with the .xlsx extension.

Unfortunately, there is no automatic data type detection, so you will have to convert numbers from text to the number data type in Excel manually. If you have a large file to process, you may want to use the csv2xlsx tool directly and set the column types with the -columns parameter:

Column ranges are a comma-separated list of numbers (e.g. 1,4,8,16), intervals (e.g. 0–4,18–32) or a combination. Each comma group can take a type specifiers for the column, one of “text”, “number”, “integer”, “currency”, date”, “standard” or “formula” separated from numbers with a colon (e.g. 0:text,3–16:number,17:date)

Note on column separators

The csv2xlsx tool does not automatically recognise what column separator the CSV file uses. It defaults to |, but in the command above, I set the -colsep parameter to , as I believe commas are more commonly used.

If you want, you can create additional context-menu items for different column separators, for example like this for semicolons:

reg add HKEY_CURRENT_USER\Software\Classes\Excel.CSV\shell\"Convert to Excel (.xlsx) [;]"\command /ve /t REG_EXPAND_SZ /d '%USERPROFILE%\csv2xlsx.exe -infile \"%1\" -colsep ; -silent -fontname Calibri -sheet Sheet1'

Changing or removing the context menu item

Open the Registry Editor (run regedit or simply search for Registry Editor in the Start menu) and navigate to HKEY_CURRENT_USER\Software\Classes\Excel.CSV\shell. There is going to be an entry for each context menu item you added.

--

--

Jonáš Jančařík

Data analyst, formerly technologist @ECThinkTank (http://medium.com/@ECThinkTank) @EU_Commission think tank.