Uncategorized

User Access Control

Introduction

User access control in Formatted Reports allows you to lock or unlock specific cells in a report, providing structured access to data. This ensures that only certain areas of the report are editable by users, helping to maintain data integrity.

Locking and Unlocking Cells

The following IronPython script demonstrates how to apply access control by locking all cells in the report and selectively unlocking a defined range of editable cells.

# IronPython

data = Qx.ToMatrix([
  ["Upload Example", "", "Date", Qx.Date("2024-01-01"), "", "Interim"],
  ["", "", "", "", "", ""],
  ["Code", "Name", "Percentage", "Value", "Select", "Comment"],
  ["DELL", "DELL STOCK",  0.45, 1000.00, "Red", ""],
  ["MSFT", "MICROSOFT STOCK",  0.30, 2500.00, "Green", ""],
  ["APPL", "APPLE CORPORATION",  0.25, 2000.00, "Blue", ""],
  ["", "", "", "", "", ""]
])

sheet = Qx.MakeStyleSheet(data)

# Lock all cells in the stylesheet
sheet.All.Locked = True

# Unlock specific editable cells
editableBlock = sheet.Box(3,2,3,4)
editableBlock.Locked = False  # Ensure cells within this range are unlocked for editing

Explanation

  1. Lock All Cells
    By default, all cells in the stylesheet are locked using:
   sheet.All.Locked = True

This ensures that no cells can be modified unless explicitly unlocked.

  1. Unlock Editable Cells
    To make a specific range editable, select the cells and set the Locked property to False:
   editableBlock = sheet.Box(3,2,3,4)  # Define the range of cells to unlock
   editableBlock.Locked = False         # Allow edits in this range

This approach is useful when you need to restrict editing to a specific section of the report, while the rest of the data remains protected.

Summary

User access control through cell locking and unlocking in Formatted Reports provides a reliable way to secure data by defining editable and non-editable sections in reports. This feature ensures that only intended cells can be modified by users, while critical data remains protected.