获取应用于单元格的验证
Contents
[
Hide
]
您可以使用 Aspose.Cells for Python via .NET 来获取应用于单元格的验证。Aspose.Cells for Python via .NET 提供了该目的的 Cell.get_validation() 方法。如果单元格上没有应用验证,则返回 null。
同样,您可以使用 Worksheet.validations.get_validation_in_cell 方法通过提供它的行和列索引来获取应用于单元格的验证。
获取应用于单元格的验证的 Python 代码
下面的代码示例演示了如何获取应用于单元格的验证。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |