简体   繁体   English

使用python \\ C#将密码插入excel工作簿

[英]insert a password into excel workbook using python \ C#

for all the python \\ C# developers: 对于所有python \\ C#开发人员:

have you ever managed to insert a password into excel workbook, using python \\ C#? 您是否曾经使用python \\ C#将密码插入excel工作簿?

couldn't find any solution using python. 使用python找不到任何解决方案。 only using VBA, which worked just fine, but the job requires python/c#... 仅使用VBA,效果很好,但这项工作需要python / c#...

thank you... 谢谢...

For a solution, you can use Microsoft.Office.Interop.Excel to open an excel file and add an password to it. 对于解决方案,可以使用Microsoft.Office.Interop.Excel打开Excel文件并向其中添加密码。

using Microsoft.Office.Interop.Excel

//create your spreadsheet here...
Application excel = new Application();
Workbook wb = excel.Workbooks.Open(path);
wb.Password = password;
wb.SaveAs("spreadsheet.xls")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM