Get Validation Applied on a Cell
You can use Aspose.Cells for Python via .NET to get the validation applied to a cell. Aspose.Cells for Python via .NET provides the Cell.get_validation() method for this purpose. If there is no validation applied on the cell, it returns null.
Similarly, you can use Worksheet.validations.get_validation_in_cell method to acquire the validation applied to a cell by providing its row and column indices.
python code to get the validation applied on a Cell
Below code sample, shows you how to get validation applied on a cell.
from aspose.cells import Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Instantiate the workbook from sample Excel file | |
workbook = Workbook("sample.xlsx") | |
# Access its first worksheet | |
worksheet = workbook.worksheets[0] | |
# Cell C1 has the Decimal Validation applied on it. It can take only the values Between 10 and 20 | |
cell = worksheet.cells.get("C1") | |
# Access the valditation applied on this cell | |
validation = cell.get_validation() | |
# Read various properties of the validation | |
print("Reading Properties of Validation") | |
print("--------------------------------") | |
print("Type: " + str(validation.type)) | |
print("Operator: " + str(validation.operator)) | |
print("Formula1: " + validation.formula1) | |
print("Formula2: " + validation.formula2) | |
print("Ignore blank: " + str(validation.ignore_blank)) |