Convert Excel (XLS, XLSX, XLSM, XLSB) to a HTML/XML File

If you have trouble running these examples see Using the Command Line and Helpful Hints For Creating a Command Line.

The first example shows how to convert a single worksheet within an Excel file to a HTML file using both the 'Convert XLS' and 'MS Excel' conversion methods. Also in the first example we'll show how to specify a specific range within a sheet(s) to convert.

The second example shows how to convert multiple sheets within a single Excel file. Creating a single and multi-file output is illustrated.

The third and final example shows how to convert one or more sheets within many Excel files within a folder (and sub-folders).

To convert to XML change the /C44 to /C46 in the examples below. Although not shown in the examples below, the /H switch could have been added to include values in addition to formulas when converting the Excel file. Furthermore, you can easily change the examples below to handle XLSX or XLSM files by changing all instances of "XLS" to "XLSX" or "XLSM" and changing all instances of "/F-4143" to "/F51" or "/F52" respectively. For XLSB files use the /M2 switch instead of /M1.

Each switch shown in blue is described in detail below the examples. It is highly recommended you review each switches description before implementing the example, thereby giving you the full power of 'Convert XLS'.

Example 1 (Single Sheet Conversion)

To convert a single XLS file, C:\in\B.XLS (Sheet named "LastSheet") to a HTML file, C:\out\B.HTM using the 'Convert XLS' conversion method, the following syntax would be used:

 

ConvertXLS.EXE /S"C:\in\B.XLS" /F-4143 /N"LastSheet" /T"C:\out\B.HTM" /C44 /M2 /V

 

Building on the last example, say you want to specify a range, say A1:B10 within a sheet to convert. No problem, modify the /N switch as shown below:

 

ConvertXLS.EXE /S"C:\in\B.XLS" /F-4143 /N"LastSheet^A1:B10" /T"C:\out\B.HTM" /C44 /M2 /V

 

Specifying ranges can be very powerful. For example if you want to only extract column N you can use "N:N" for the range.

 

To do the same using the 'MS Excel' conversion method (slower and MS Excel is required) change the /M2 switch to /M1 as shown below:

 

ConvertXLS.EXE /S"C:\in\B.XLS" /F-4143 /N"LastSheet" /T"C:\out\B.HTM" /C44 /M1 /V

 

Example 2 (Multiple Sheet Conversion)

In example 1 we saw how the /N switch is used to specify the sheet/range to. Here we build upon that and show how to specify more than one sheet to convert.

To convert a single XLS file, C:\in\B.XLS (Sheets named "LastSheet","FirstSheet", and "MidSheet") to one HTM file, C:\Out\B.HTM, the following syntax would be used:

 

ConvertXLS /S"C:\in\B.XLS" /F-4143 /N"FirstSheet,LastSheet,MidSheet" /T"C:\Out\B.HTM" /C44 /M2 /V

 

After completion of this example the following file will be created containing all the data of the 3 sheets specified:

 C:\Out\B.HTM

 

To create several output files you can add the /U switch like so:

ConvertXLS /S"C:\in\B.XLS" /F-4143 /N"FirstSheet,LastSheet,MidSheet" /T"C:\Out\B.HTM" /C44 /M2 /U /V

 

After completion the output would be several files:

C:\Out\B-FirstSheet.HTM

C:\Out\B-MidSheet.HTM

C:\Out\B-LastSheet.HTM

 

VERY IMPORTANT NOTE: The /U switch is only applicable to the 'Convert XLS' (/M2) conversion method.

If FirstSheet, MidSheet, and LastSheet were indexed 1,2 and 4 respectively, the same results can be attained by setting /N To /N"1-2,4".

 

Example 3 (Multiple File/Folder Conversion)

Say you wanted to convert the 2nd sheet (/N"2") regardless of what the sheet name might be, of all the XLS files within the "C:\in" folder and sub-folders (/R for recursive sub-folders). To do this the syntax would be:

 

ConvertXLS.EXE /S"C:\in\*.XLS" /F-4143 /N"2" /T"C:\out\*.HTM" /C44 /M2 /R /V

 

The example above can be modified to have the output files placed in the same folder as the input files. To do this specify the /G switch and remove the /T switch as shown below:

 

ConvertXLS.EXE /S"C:\in\*.XLS" /F-4143 /N"2" /G /C44 /M2 /R /V

 

In the last two examples, you can also use the /M1 switch to specify the 'MS Excel' conversion method.

 

Sheet: Only used when an Excel file is the input file. Use "*" or "" for all sheets. You can use names of sheets, or the numeric index. If using numeric indices, you can specify ranges of sheets (i.e. "1,4,10-20" and "4-10,9" etc.). Range and DelimChar are optional.

Range: You could optionally specify a range, say if you only wanted to convert a portion of the input file. Use the same syntax as an Excel range (e.g. A1:B10).

DelimChar: Not useful in these examples. It is for specifying the ASCII value of the delimitation character used in a CSV file. 44 for comma, 124 for Bar "|", 9 for the tab etc.

FixedWidth: Not useful in these examples. Here you can specify how to import/export a fixed width text file. Not used in this example.

Note: It is highly encouraged that you use the Verbose (/V) switch initially to see what the status of your conversion is and to help you perfect your command line. When in verbose mode the program will tell you what went wrong or right with your command line using message boxes.