[Python] Accessing Excel File protected by IRM using Python

Discussão em 'Python' iniciado por Stack, Setembro 17, 2025.

  1. Stack

    Stack Membro Participativo

    I need to process some regular Excel files every week.

    The files are password protected but I know I can Open them using msoffcrypto with the password.

    The problem is we protect the files with IRM encryption on top and when I try to open the files (on a system with authorized credentials) I can't seem to do it.

    MSOFfCrypto just says the password is invalid even though it is not.

    With mscryptooff I convert the file to a byte stream using the IO import and load it openpyxl, based on this question: stackoverflow.com/questions/75069675/… but its always gives me and InvalidKeyException saying the password is incorrect. It does work if I manually remove Microsoft IRM but Since its so many files weekly it's simply not viable to do ir by hand.

    Is there anyway to pass the credentials to the IRM as well?

    Continue reading...

Compartilhe esta Página