DevExpress SpreadSheetControl 单元格解除保护

IWorkbook workbook = spreadsheetControl1.Document;

workbook.BeginUpdate();
Worksheet worksheet = workbook.Worksheets[0];
            
Style lockedStyle = workbook.Styles.Add("UnLocked");
lockedStyle.Protection.Locked = false;
lockedStyle.Borders.SetAllBorders(Color.Red, BorderLineStyle.Thin);

workbook.Styles[0].Protection.Locked = true;
worksheet["C3:E8"].Style = lockedStyle;

if ( !worksheet.IsProtected )
    worksheet.Protect("132", WorksheetProtectionPermissions.Default);

workbook.EndUpdate();

简化版

Worksheet worksheet = spreadsheetControl1.Document.Worksheets[0];
worksheet["C3:B8"].Borders.SetAllBorders(Color.Red, BorderLineStyle.Thin);
worksheet["$A:$XFD"].Protection.Locked = true; // lock the entire document
worksheet["C3:B8"].Protection.Locked = false; // Unlock  the specified range
worksheet.Protect("password", WorksheetProtectionPermissions.Default);





你可能感兴趣的:(DevExpress SpreadSheetControl 单元格解除保护)