Я хочу, чтобы пользователи могли помечать определенные области как заблокированные в своих шаблонах, но похоже, что Xlsio устанавливает для свойства Range.CellStyle.Locked значение false по умолчанию, даже если вы помечаете диапазон как редактируемый в Excel. Есть ли способ это исправить?
Вот мой код:
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<string>() { ".xlsx" });
//Creates a storage file from FileSavePicker
StorageFile outputStorageFile = await savePicker.PickSaveFileAsync();
//Saves changes to the specified storage file
await workbook.SaveAsAsync(outputStorageFile);
![Some cells are unlocked](https://i.stack.imgur.com/QUveS.png)