最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin16PV0评论

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.

Post a comment

comment list (0)

  1. No comments so far