【问题标题】:Is there a way to set sensitivity label in Excel using Pandas Dataframes?有没有办法使用 Pandas Dataframes 在 Excel 中设置敏感度标签?
【发布时间】:2019-07-28 20:50:59
【问题描述】:

我有一个使用 Pandas 数据框生成的 excel 文件。我想在 Excel 文件中添加 Python 中的“公共”、“机密”等敏感度标签。

This link shows the normal way of adding the sensitivity label in Office 365

但是,我想用代码完成同样的事情。

OpenPyxl 确实提供了一种添加密码的方法,但不提供敏感度标签。

【问题讨论】:

    标签: python excel python-3.x pandas dataframe


    【解决方案1】:

    你可以用 xlsxwriter 来做,我不知道如何用 pandas 来做

    您可以使用os package chmod更改文件创建时的模式

    from xlsxwriter.workbook import Workbook
    
    book = Workbook('file/path')
    sheet = book.add_worksheet('worksheet_name')
    
    # Add separate format for unlocked cells
    unlocked = book.add_format({'locked': 0})
    # Protect all cells in your sheet by default
    sheet.protect()
    

    【讨论】:

    • 感谢您的回复。上面的答案只是保护文件/工作簿/工作表。我今天找到了这个链接:docs.microsoft.com/en-us/information-protection/develop。我想要在 Python 中使用同样的东西,我可以在其中读取和修改敏感度标签。
    • @Akshay 你用 xlsxwriter 找到解决方案了吗?
    猜你喜欢
    • 2022-06-14
    • 1970-01-01
    • 1970-01-01
    • 2010-09-26
    • 1970-01-01
    • 2021-05-31
    • 2019-10-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多