Add a password (unattended) to existing xlsx without Windows exclusive tools

前端 未结 1 1801
温柔的废话
温柔的废话 2021-01-23 03:39

I\'m generating an xlsx file using Openpyxl. And i\'d like to protect the workbook itself using a password that I have as a variable in the same script. This ca

1条回答
  •  天涯浪人
    2021-01-23 03:44

    What you're asking for isn't currently available in any Python package. The best you can probably do for now is to install a package implemented in some other language, and call that package from Python (using os.system() or the subprocess module or something along those lines).

    The two that I know of are

    • https://github.com/ankane/secure-spreadsheet (Node.js)
    • https://github.com/herumi/msoffice (C++)

    secure-spreadsheet is basically a command-line wrapper for xlsx-populate.

    It seems like you want to be able to do this without having Excel installed, but for completeness I'll mention that if you do have Excel installed, then another way to do this is to automate Excel itself, which can be done in Python using xlwings, or the underlying packages that it depends upon: pywin32 on Windows or appscript on Mac.

    0 讨论(0)
提交回复
热议问题