Users cannot sort rows when sheet is protected

Posted by: david.sheppard on 17 July 2023, 1:23 am EST

    • Post Options:
    • Link

    Posted 17 July 2023, 1:23 am EST

    I want the users to be able to sort the rows in a spread control, but I do not want them to be able to edit the values in the cells. I am using the asworkbook().activiesheet.protect command shown below to protect the sheet. I am using the columns(index).AllowAutoSort command to make the columns sortable. When I do not protect the worksheet, users can sort the rows by clicking on the caret in the column heading. When I protect the worksheet, users cannot sort. I am using spread version 16.0.20221.3.

    fpspread1.AsWorkbook().ActiveSheet.Protect(GrapeCity.Spreadsheet.WorksheetLocks.All And

    Not GrapeCity.Spreadsheet.WorksheetLocks.FormatColumns And

    Not GrapeCity.Spreadsheet.WorksheetLocks.SelectUnlockedCells And

    Not GrapeCity.Spreadsheet.WorksheetLocks.SelectLockedCells And

    Not GrapeCity.Spreadsheet.WorksheetLocks.FormatRows)

  • Posted 17 July 2023, 9:14 pm EST

    Found it myself. There is an option to lock/unlock sort. I added it to the protect:

    Fpspread1.AsWorkbook().ActiveSheet.Protect(

    GrapeCity.Spreadsheet.WorksheetLocks.All And

    Not GrapeCity.Spreadsheet.WorksheetLocks.FormatColumns And

    Not GrapeCity.Spreadsheet.WorksheetLocks.SelectUnlockedCells And

    Not GrapeCity.Spreadsheet.WorksheetLocks.SelectLockedCells And

    Not GrapeCity.Spreadsheet.WorksheetLocks.FormatRows And

    Not GrapeCity.Spreadsheet.WorksheetLocks.Sort)

  • Posted 18 July 2023, 1:44 am EST

    Hi David,

    It’s good to see that you were able to find the answer to your question on your own. If you have any further questions or need assistance in the future, please feel free to ask.

    Thanks & Regards,

    Aastha

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels