【问题标题】:Synfusion XlsIO doesn't respect Excel's "Allow users to edit ranges" option when loading excel filesSyncfusion XlsIO 在加载 excel 文件时不尊重 Excel“允许用户编辑范围”选项
【发布时间】: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


    【解决方案1】:

    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

    【讨论】:

      【解决方案2】:

      XlsIO 不支持“允许用户编辑范围”功能。但是,您可以通过解锁来编辑工作表中所需的范围(即将CellStyleLocked 属性设置为false)。我们根据您的要求准备了样品,可以从以下链接下载。

      示例链接:http://www.syncfusion.com/downloads/support/directtrac/general/ze/Modified_Sample-804271761.zip

      注意:我为syncfusion工作

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-10-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多