使用openxml在excel单元格上应用密码保护 [英] Applying Password protection on excel cell using openxml
本文介绍了使用openxml在excel单元格上应用密码保护的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的朋友们,
我正在通过 OpenXMl功能在我的应用程序中下载和excel文件。在这里,我必须在某些列上应用Lock,但不要在每张列上应用Lock。
我可以通过以下代码锁定整个表: -
Dear Friends,
I am downloading and excel file in my application through OpenXMl feature. Here I have to Apply Lock on some of the Columns but not on every column of he sheet.
I am able to lock the whole sheet by the following code:-
//************Sheet Protection******************
Protection objProtection = new Protection();
objProtection.Locked = true;
cellFormat.ApplyProtection = true;
cellFormat.Append(objProtection);
SheetProtection objStyleSheetP = new SheetProtection();
objStyleSheetP.Password = "123";
objStyleSheetP.Sheet = true;
objStyleSheetP.Objects = true;
objStyleSheetP.Scenarios = true;
styleSheet.CellFormats.Append(cellFormat);
workSheet.InsertAfter(objStyleSheetP, workSheet.Elements<SheetData>().First());
//***********Till Here********************
我已经尝试了很多搜索谷歌但都徒劳无功。任何人都可以帮我找到确切的代码或想法如何解决。
谢谢&问候
Varun Sareen
I have tried a lot to search on google but all in vain. Can anyone please help me finding the exact code or an idea how to work it out.
Thanks & Regards
Varun Sareen
推荐答案
这篇关于使用openxml在excel单元格上应用密码保护的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文