Excel for WinRT
Locked Property (XLSheet)
Example 


Gets or sets a value that determines if the sheet is locked for editing.
Syntax
'Declaration
 
Public Property Locked As System.Boolean
'Usage
 
Dim instance As XLSheet
Dim value As System.Boolean
 
instance.Locked = value
 
value = instance.Locked
public System.bool Locked {get; set;}
Remarks

Sheets and styles can be locked. By default, sheets are unlocked and styles are locked. This combination allows users to edit the cells in Excel.

To protect a cell against editing in Excel, both the sheet and the cell style must have the Locked property set to true.

To lock most cells on a sheet and allow editing of only a few cells, lock the sheet, then create an unlocked style and assign it to the cells that should be editable.

Example
The code below creates a data entry sheet. Most cells are locked, except for the ones where the user is supposed to enter data.
// start with a single locked sheet
_c1xl.Clear();
XLSheet sheet = _c1xl.Sheets[0];
sheet.Locked = true;
            
// create an unlocked style
XLStyle dataEntry = new XLStyle(_c1xl);
dataEntry.Locked = false;
dataEntry.BackColor = Color.Beige;
            
// create data entry titles
sheet[0,0].Value = "Name:";
sheet[1,0].Value = "Address:";
sheet[2,0].Value = "Phone #:";
            
create data entry cells (unlocked)
sheet[0,1].Style = dataEntry;
sheet[1,1].Style = dataEntry;
sheet[2,1].Style = dataEntry;
            
// save the book
_c1xl.Save(@"c:\temp\Protected.xls");
See Also

Reference

XLSheet Class
XLSheet Members

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback