Link Search Menu Expand Document

Convert Excel file into XML - Python

XLS/XLSX to XML sample in Python demonstrating ‘Convert Excel file into XML’
import os
import requests  # pip install requests
import json

# The authentication key (API Key).
# Get your own by registering at
API_KEY = "***************************************"

# Base URL for Web API requests

# Direct URL of source xls file.
SourceFileURL = ""

def main(args = None):

def convertXlsToXml(sourceFileUrl):
    """Convert Xls/Xlsx to Xml using Web API"""

    # Prepare requests params as JSON
    parameters = {
        "url": sourceFileUrl,
        "async": False

    # Prepare URL for 'Xls to Xml' API request
    url = "{}/xls/convert/to/xml".format(BASE_URL)

    # Execute request and get response as JSON
    response =, headers={ "x-api-key": API_KEY, "Content-Type": "application/json" }, data=json.dumps(parameters))
    if (response.status_code == 200):
        json_res = response.json()

        if json_res["error"] == False:
            # Get URL of result file
            resultFileUrl = json_res["url"]
            # Output URL of converted xml file
            print(f"Result file url: {resultFileUrl}")
            # Show service reported error
        print(f"Request error: {response.status_code} {response.reason}")

if __name__ == '__main__':
    main() Web API: the Web API with a set of tools for documents manipulation, data conversion, data extraction, splitting and merging of documents. Includes image recognition, built-in OCR, barcode generation and barcode decoders to decode bar codes from scans, pictures and pdf.

Get your API key here!

Download Source Code (.zip)

return to the previous page explore XLS/XLSX to XML endpoint