admin管理员组

文章数量:1323716

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.

本文标签: