How to use Application.FileConverters in the xlwings API way

The FileConverters property of the Application object in Excel provides a list of file converters that are currently installed and available for use. This is particularly useful when you need to programmatically determine which file formats Excel can open or save through external converters, such as older file types (e.g., Lotus 1-2-3, Quattro Pro) or specialized formats. In xlwings, this property can be accessed to retrieve information about these converters, enabling automation tasks that depend on specific file format support.

Functionality:
The FileConverters property returns a two-dimensional array (list of lists in Python) that contains details about each installed file converter. Each converter entry typically includes the converter’s descriptive name, the file extension it handles, and a class identifier. This information can be used to check for the availability of a converter before attempting to open or save a file in a non-native format, ensuring compatibility and preventing errors in automated workflows.

Syntax in xlwings:
In xlwings, you access the FileConverters property through the app object, which represents the Excel application. The syntax is straightforward:

app.api.FileConverters

This returns a Variant array in Excel’s object model, which xlwings converts into a Python list. The array is structured as a collection of sub-arrays, where each sub-array corresponds to one converter. The elements within each sub-array represent:

  • Index 0: The converter’s descriptive name (e.g., “Lotus 1-2-3”).
  • Index 1: The file extension associated with the converter (e.g., “.wk3”).
  • Index 2: A class identifier or internal number for the converter.

If no converters are installed, the property returns None or an empty array in Python, depending on the Excel version and configuration.

Code Examples:
Here are practical examples using xlwings to work with the FileConverters property:

  1. Retrieve and list all installed file converters:
import xlwings as xw

# Connect to the active Excel instance or start a new one
app = xw.apps.active

# Get the file converters
converters = app.api.FileConverters

# Check if converters exist and iterate through them
if converters:
    for converter in converters:
        print(f"Name: {converter[0]}, Extension: {converter[1]}, Class ID: {converter[2]}")
else:
    print("No file converters installed.")

This code prints details for each converter, helping you audit available formats.

  1. Check for a specific converter by file extension:
import xlwings as xw

app = xw.apps.active
converters = app.api.FileConverters
target_extension = ".wk3" # Example for Lotus 1-2-3 files

found = False
if converters:
    for converter in converters:
        if converter[1] == target_extension:
            print(f"Converter found: {converter[0]} for {target_extension}")
            found = True
            break
if not found:
    print(f"No converter for {target_extension} is installed.")

This example verifies support for a particular file type before proceeding with operations.

  1. Use in a function to validate file format support:
import xlwings as xw

def is_converter_available(extension):
app = xw.apps.active
converters = app.api.FileConverters
if converters:
    for converter in converters:
        if converter[1].lower() == extension.lower():
            return True
        return False

# Example usage
if is_converter_available(".slk"):
    print("SYLK format is supported.")
else:
    print("SYLK format is not supported.")

This function can be integrated into larger scripts to handle file conversions dynamically.

June 7, 2026 (0)


Leave a Reply

Your email address will not be published. Required fields are marked *