[Python] Error opening Excel file in python edited on Excel Web Interface

Discussão em 'Python' iniciado por Stack, Março 20, 2025.

  1. Stack

    Stack Membro Participativo

    Problem:

    I'm encountering issues when trying to open Excel files (.xlsx) with pandas that was edited on SharePoint Online (Microsoft 365) via the web Excel interface and then downloaded.

    Code and Errors:

    import pandas as pd

    # Attempt to read the Excel file with various engines
    # Auto
    df = pd.read_excel('file_path.xlsx')
    # Error: XLRDError: Can't find workbook in OLE2 compound document

    # openpyxl
    df = pd.read_excel('file_path.xlsx', engine='openpyxl')
    # Error: BadZipFile: File is not a zip file

    # calamine
    import calamine
    df = calamine.read_excel('file_path.xlsx', engine='calamine')
    # Error: CalamineError: Cannot detect file format

    # pyxlsxb
    import pyxlsb
    df = pyxlsb.read_excel('file_path.xlsx', engine='pyxlsb')
    # Error: BadZipFile: File is not a zip file


    Additional Details:

    1. The same .xlsx file is opened without errors on desktop Excel.
    2. Just for a test, I tried to open such "corrupted" .xlsx with Excel and save it to another file and later open that new .xlsx but that did not resolve the error.
    3. The error persists across different library versions.

    Has anyone encountered this problem or have suggestions on how to resolve it?

    Continue reading...

Compartilhe esta Página