We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

XlsIO doesn't respect Excel's "Allow users to edit ranges" option when loading excel files

I want the users to be able to mark certain areas to be locked in their templates, but it seems that Xlsio sets Range.CellStyle.Locked property to false by default even if you mark the range to be editable in Excel. Is there a way to fix that?
Here is my code:

ExcelEngine excelEngine = new ExcelEngine();
var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Template.xlsx", UriKind.Absolute));
//Loads or open an existing workbook
IWorkbook workbook = await excelEngine.Excel.Workbooks.OpenAsync(file);
workbook.Version = ExcelVersion.Excel2013;
workbook.Protect(true, true, "111");
foreach(var sheet in workbook.Worksheets)
//Initializes FileSavePicker
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.Desktop;
savePicker.SuggestedFileName = "output";
savePicker.FileTypeChoices.Add("Excel Files", new List() { ".xlsx" });
//Creates a storage file from FileSavePicker
StorageFile outputStorageFile = await savePicker.PickSaveFileAsync();
//Saves changes to the specified storage file
await workbook.SaveAsAsync(outputStorageFile);

Attachment: XlsioProtectRepro_90df710e.zip

1 Reply

AV Abirami Varadharajan Syncfusion Team April 15, 2019 07:59 AM

Hi Muhammad,

We don’t have support for “Allow users to edit ranges” feature. However, you can edit the desired range in the worksheet by unlocking it(i.e., by setting Locked property of CellStyle to false). We have modified the sample as per your requirement which can be downloaded from following link. 

Kindly try and let us know if this helps at your end. 


Live Chat Icon For mobile
Up arrow icon