Protected sheet skin

Posted by: mark on 23 November 2019, 11:26 pm EST

    • Post Options:
    • Link

    Posted 23 November 2019, 11:26 pm EST

    When I protect a sheet, the column and row header text fades out to an extent such that it is difficult to read. Any idea how I can prevent this from happening or how I can change the font for headers of a protected sheet.

    Thanks,

    Mark

  • Posted 24 November 2019, 11:19 pm EST

    Hi Mark,

    To change the forecolor of header cells when the sheet is locked, please use the following code:```

    foreach (FarPoint.Win.Spread.Column column in fpSpread1.ActiveSheet.ColumnHeader.Columns)

    {

    FarPoint.Win.Spread.Cell cell = fpSpread1.ActiveSheet.ColumnHeader.Cells[0, column.Index];

    cell.Locked = true;

    cell.Renderer = new GeneralCellType();

    cell.LockForeColor = Color.Black;

    }

    foreach (FarPoint.Win.Spread.Row row in fpSpread1.ActiveSheet.RowHeader.Rows)

    {

    FarPoint.Win.Spread.Cell cell = fpSpread1.ActiveSheet.RowHeader.Cells[row.Index, 0];

    cell.Locked = true;

    cell.Renderer = new GeneralCellType();

    cell.LockForeColor = Color.Black;

    }

    
    Also, attached is sample application for reference. 
    
    Regards,
    Ruchir
    [zip filename="Spread_ProtectedSheet.zip"]https://gccontent.blob.core.windows.net/forum-uploads/file-d91d2d05-96e8-4a66-9589-d7558fd2d224.zip[/zip]
  • Posted 7 September 2023, 6:15 am EST

    This works, but the gridlines separating columns disappears, which is annoying. How do I get them back? Also, why does the sheet have to be protected to have the Locked properties work?

    Finally, is there a way to have the behaviour of a locked cell without protecting the whole sheet?

  • Posted 7 September 2023, 6:39 pm EST

    Hi Vijay,

    This works, but the gridlines separating columns disappears, which is annoying. How do I get them back?

    You can set the border of the locked cell headers as shown in the following updated code-snippet:

    foreach (FarPoint.Win.Spread.Column column in fpSpread1.ActiveSheet.ColumnHeader.Columns)
    {
        FarPoint.Win.Spread.Cell cell = fpSpread1.ActiveSheet.ColumnHeader.Cells[0, column.Index];
        cell.Locked = true;
        cell.Renderer = new GeneralCellType();
        cell.LockForeColor = Color.Black;
        cell.Border = new ComplexBorder(new ComplexBorderSide(ComplexBorderSideStyle.ThinLine, Color.LightGray));
    }
    foreach (FarPoint.Win.Spread.Row row in fpSpread1.ActiveSheet.RowHeader.Rows)
    {
        FarPoint.Win.Spread.Cell cell = fpSpread1.ActiveSheet.RowHeader.Cells[row.Index, 0];
        cell.Locked = true;
        cell.Renderer = new GeneralCellType();
        cell.LockForeColor = Color.Black;
        cell.Border = new ComplexBorder(new ComplexBorderSide(ComplexBorderSideStyle.ThinLine, Color.LightGray));
    }

    Kindly refer to the attached sample for full implementation. (See Spread_ProtectedSheet.zip)

    Also, why does the sheet have to be protected to have the Locked properties work?

    As per the design behavior of Spread.NET control, the user can still interact with cells marked as locked when the Protect property is false. Therefore, it is required to enable the Protect property of the SheetView object to lock the cells it contains.

    Please refer to the following link for more information regarding the same: https://www.grapecity.com/spreadnet/docs/latest/online-win/spwin-celllock.html

    Finally, is there a way to have the behaviour of a locked cell without protecting the whole sheet?

    Unfortunately, there is no other way to set the locked cells without protecting the whole sheet.

    In case you are facing any particular issue because of protecting the whole sheet, kindly let us know.

    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