Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
XL.Sheet.SetProtect
Protects/unprotects the sheet.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
XL | 3.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example |
---|---|---|
bookRef | The reference to the workbook. Please use XL.LoadBook to load a file. | $ref |
sheetIndex | The index of the sheet. This number ranges from 0 to XL.Book.SheetCount-1. | 0 |
Value | The new setting. | 1 |
Result
Returns OK or error message.
Description
Protects/unprotects the sheet.Examples
Protect the 3rd sheet:
MBS( "XL.Sheet.SetProtect"; $book; 2; 1)
Write cell locked and protect sheet:
# create format
Set Variable [ $lockFormat ; Value: MBS( "XL.Book.AddFormat"; $book) ]
Set Variable [ $r ; Value: MBS( "XL.Format.SetLocked"; $book; $lockFormat; 1) ]
# add sheet
Set Variable [ $sheet ; Value: MBS( "XL.Book.AddSheet"; $book; "test") ]
# and write a locked cell
Set Variable [ $r ; Value: MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 5; 5; "Locked text"; $lockFormat) ]
# protect sheet
Set Variable [ $r ; Value: MBS( "XL.Sheet.SetProtectEx"; $book; $sheet; 1; "test"; "all") ]
See also
- XL.Book.AddFormat
- XL.Book.AddSheet
- XL.Book.SheetCount
- XL.Format.SetLocked
- XL.LoadBook
- XL.Sheet.GetProtect
- XL.Sheet.SetPaper
- XL.Sheet.SetPrintFit
- XL.Sheet.SetPrintRow
- XL.Sheet.SetProtectEx
This function checks for a license.
Created 18th August 2014, last changed 7th September 2022