Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: protect an area

$
0
0
what I have done is the following (the exact syntax might be different for you, depending on the development environment that you are using):
  1. when you create the sheet, release the ranges that you do not want to protect. I used a command like xlWrkshtDotNet.Range(UseRange).Style.Protection.SetLocked(FALSE) for this, where UseRange is a variable, containing the cell, column or row that you do not want to protect. I have used this command every time I had a cell or range that I did not want to protect during the creation process (find that easier than doing it at the end)
  2. at the end of the process of creating the sheet I used xlWrkshtDotNet.Protect(GetPassword) to protect the entire sheet, but the range(s) that I had specified in the first command SETLOCKED(FALSE) will not be protected by this command. I used a function GetPassword to make it possible to dynamically set a document-specific password (it's return variable is a password).

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>