File Format & Compatibility

How to Convert Excel XML to XLS from the Command Line

Kushani NimanthikaKushani Nimanthika Nov 2, 2026 870 views

Question details

The user needs a method to convert Excel XML report files to the older XLS format via the command line or a DLL so users with legacy Excel versions can open them without errors.

How to Convert Excel XML to XLS from the Command Line
Product
Microsoft Excel
Device & OS
not provided
Scenario
A third-party reporting tool generates reports in Excel XML format, which fail to open in older versions of Excel unless converted to the standard Excel 97-2003 (XLS) format.
Observed behavior
Simply renaming the file extension from .xml to .xls is unreliable and causes errors for users on older Excel versions, as it does not actually change the internal file structure.
Before you start

Before attempting command-line conversion, verify that your original XML file is a properly structured Excel Spreadsheet XML and can be opened manually in a modern spreadsheet application.

Solution 1Recommended

Automate Excel 'Save As' Using a PowerShell Script

Since Excel lacks a native command-line conversion switch, you can write a PowerShell script using the Excel COM object to silently open the XML and save it as an XLS file.

Microsoft Excel does not offer a built-in executable parameter for converting file formats directly from the command prompt. However, you can achieve the exact equivalent of 'Save As Excel 97-2003 Workbook' by interacting with Excel's COM automation interface via a script.

1
Initialize the Excel COM Object

Open Notepad and start a new PowerShell script. Create the Excel application object using the command: $excel = New-Object -ComObject Excel.Application.

2
Open the XML file

Instruct the script to open your target XML report by adding: $workbook = $excel.Workbooks.Open('C:\path\to\your\report.xml').

3
Execute the SaveAs command

Save the file in the XLS format (Format ID 56) by adding: $workbook.SaveAs('C:\path\to\output.xls', 56).

4
Run the script from the command line

Save your script as 'Convert-XMLtoXLS.ps1'. You can now trigger this conversion from the command line by executing: powershell.exe -ExecutionPolicy Bypass -File Convert-XMLtoXLS.ps1.

Automate Excel 'Save As' Using a PowerShell Script
Requires Local Excel Installation: This automation method relies on the Microsoft Excel application. Excel must be installed on the machine running the PowerShell script for the COM object to function correctly.

Easily Convert XML Reports to XLS with WPS Spreadsheet

If you are dealing with frequent format compatibility issues, WPS Office offers a free, lightweight solution. WPS Spreadsheet seamlessly opens Excel XML reports and allows you to quickly save them as highly compatible XLS files, ensuring users on legacy systems can access their data without errors.

  1. 1. Open your XML file in WPS: Launch WPS Spreadsheet and drag-and-drop your generated XML report directly into the workspace.
  2. 2. Click on Save As: Click the Menu button in the top left corner, then hover over the 'Save As' option.
  3. 3. Save in XLS format: Select 'Microsoft Excel 97-2003 Workbook (*.xls)' from the available options to create a fully compatible file.
Completely free and lightweight office suiteFully compatible with Microsoft Excel 97-2003 (XLS) formatsSeamlessly opens and parses Excel XML reportsFamiliar user interface makes manual conversions quick and easy
microsoft office alternative - wps office

Frequently Asked Questions

Why does renaming an XML file to XLS not work?

Changing a file's extension only changes its name, not its underlying data structure. An XML file is text-based, whereas a true legacy XLS file is a binary format. Older Excel versions expect the binary structure and will throw an error if they encounter plain text XML.

Are there standard Excel command-line switches to convert file formats?

No. Microsoft Excel does not provide native command-line parameters (like a simple switch) to convert files from one format to another or to trigger the 'Save As' command silently.

Can I automate this conversion on a background server?

While it is possible to use COM automation via PowerShell or VBScript, Microsoft explicitly advises against automating Office applications in an unattended server environment. For servers, it is highly recommended to use dedicated third-party conversion DLLs or APIs.

What is the correct file format ID for saving as XLS via COM?

When using the SaveAs method in an automation script, the file format ID for an Excel 97-2003 Workbook (.xls) is 56.