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?
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)
{
sheet.Protect("111");
}
//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);