How to Read an Existing Excel File Directly from M-Files via API?


I’m working on integrating M-Files with an external Python application. I want to read the contents of an existing Excel file stored in M-Files directly through the API, ideally without having to download the file to local storage first.

Is it possible to access and read the Excel file’s data directly via the M-Files REST or COM API? If so, could you please share some guidance or sample code?

Thanks in advance for your help!

Parents Reply
  • Thank you for your input! Accessing the file content directly via the "contents" endpoint and reading it into memory worked perfectly for my use case — no need to save the file locally.

    Here’s a simplified example of how I read the Excel file from the response stream into a pandas DataFrame:

    import requests
    import pandas as pd
    from io import BytesIO

    # Assume 'download_url' and 'headers' are already set up correctly
    response = requests.get(download_url, headers=headers, stream=True)
    response.raise_for_status()

    excel_data = BytesIO(response.content)
    df = pd.read_excel(excel_data)

    print(df.head()) # Confirm data is loaded

    Thanks again for clarifying — this approach is exactly what I needed!

Children
No Data