最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

.net - select unlocked cell and selecrt locked cell is not working on the sheetprotection in openXML, C# - Stack Overflow

programmeradmin33浏览0评论

I am trying to protect an excel sheet where the cells can be selected but not editable I have made the cells unlocked in the cell format but the selection is disabled once the Excel file is opened.

SheetProtection sheetProtection = new SheetProtection
{
SelectLockedCells = true, // Allow selection of locked cells
SelectUnlockedCells = true
Sheet = true,             // Enable sheet protection
Objects = true,           // Protect objects (like charts)
Scenarios = true,         // Protect scenarios
FormatCells = false,      // Prevent formatting of locked cells
FormatColumns = false,    // Prevent formatting columns
FormatRows = false,       // Prevent formatting rows

                };
                sheetPart.Worksheet.InsertAfter(sheetProtection, sheetData);

In the XML file it is reflected the sheet protection and select unlocked and locked cells are true.

<x:sheetProtection sheet="1" objects="1" scenarios="1" formatCells="0" formatColumns="0" formatRows="0" selectLockedCells="1" selectUnlockedCells="1" />

expectation is the excel sheet were the cells can selectable, so the unlocked cells can be edited.

发布评论

评论列表(0)

  1. 暂无评论