الحصول على التحقق المطبق على خلية ما
يمكنك استخدام Aspose.Cells للحصول على التحقق المطبق على خلية. توفر Aspose.Cells الأسلوب Cell.GetValidation() لهذا الغرض. إذا لم يتم تطبيق التحقق على الخلية، يعيد قيمة فارغة.
بالمثل، يمكنك استخدام الأسلوب Worksheet.Validations.GetValidationInCell للحصول على التحقق المطبق على خلية عن طريق توفير مؤشرات الصف والعمود الخاصة بها.
كود C# للحصول على التحقق المطبق على الخلية
توضح العينة البرمجية التالية كيفية الحصول على التحقق المطبق على خلية.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Instantiate the workbook from sample Excel file | |
Workbook workbook = new Workbook(dataDir + "sample.xlsx"); | |
// Access its first worksheet | |
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 cell = worksheet.Cells["C1"]; | |
// Access the valditation applied on this cell | |
Validation validation = cell.GetValidation(); | |
// Read various properties of the validation | |
Console.WriteLine("Reading Properties of Validation"); | |
Console.WriteLine("--------------------------------"); | |
Console.WriteLine("Type: " + validation.Type); | |
Console.WriteLine("Operator: " + validation.Operator); | |
Console.WriteLine("Formula1: " + validation.Formula1); | |
Console.WriteLine("Formula2: " + validation.Formula2); | |
Console.WriteLine("Ignore blank: " + validation.IgnoreBlank); |