有没有办法使用 Pandas Dataframes 在 Excel 中设置敏感度标签?

Aks*_*hay 8 python excel dataframe python-3.x pandas

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

此链接显示了在 Office 365 中添加敏感度标签的正常方法

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

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

Nus*_*ath -2

你可以用xlsxwriter来做到这一点,但我不知道如何用 pandas 做到这一点

或者

os您可以在使用包创建文件时更改文件的模式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()
Run Code Online (Sandbox Code Playgroud)

  • 谢谢回复。上面的答案只是保护文件/工作簿/工作表。我今天找到了这个链接:https://learn.microsoft.com/en-us/information-protection/develop/。我想要在 Python 中实现同样的功能,以便我可以读取和修改敏感度标签。 (3认同)