Få validering som tillämpats på en cell
Du kan använda Aspose.Cells for Python via .NET för att få validering som har tillämpats på en cell. Aspose.Cells for Python via .NET tillhandahåller metoden Cell.get_validation() för detta ändamål. Om det inte finns någon validering som har tillämpats på cellen returnerar den null.
På liknande sätt kan du använda metod Worksheet.validations.get_validation_in_cell för att få validering som har tillämpats på en cell genom att ange dess rad- och kolumnindex.
Pythonkod för att få validering som har tillämpats på en cell
Nedan följer ett kodexempel som visar hur du får validering som har tillämpats på en 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)) |