我希望用户能够标记要锁定在其模板中的某些区域,但是,即使您将范围标记为在Excel中可编辑,Xlsio似乎也默认将Range.CellStyle.Locked属性设置为false。有办法解决吗? 这是我的代码:
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);
答案 0 :(得分:0)
Xlsio似乎不支持“允许用户编辑范围”功能:https://www.syncfusion.com/forums/144011/xlsio-doesn39t-respect-excel39s-quotallow-users-to-edit-rangesquot-option-when-loading-excel-files
我们不支持“允许用户编辑范围”功能。但是,您可以通过解锁来编辑工作表中的所需范围(即,将CellStyle的Locked属性设置为false)。我们已根据您的要求修改了样本,可以从以下链接下载该样本。
示例链接:http://www.syncfusion.com/downloads/support/directtrac/general/ze/Modified_Sample-804271761.zip
答案 1 :(得分:0)
XlsIO不支持“允许用户编辑范围”功能。但是,您可以通过解锁工作表来编辑所需的范围(即,将Locked的CellStyle属性设置为false)。我们已根据您的要求准备了样本,可以从以下链接下载。
示例链接:http://www.syncfusion.com/downloads/support/directtrac/general/ze/Modified_Sample-804271761.zip
注意:我正在进行融合