【发布时间】:2019-04-14 20:43:52
【问题描述】:
我希望用户能够在其模板中标记要锁定的某些区域,但 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);
【问题讨论】:
标签: excel uwp syncfusion