الحصول على التحقق المطبق على خلية باستخدام C++
Contents
[
Hide
]
يمكنك استخدام Aspose.Cells للحصول على التحقق المطبق على خلية. توفر Aspose.Cells الأسلوب Cell::GetValidation() لهذا الغرض. إذا لم يتم تطبيق التحقق على الخلية، يعيد قيمة فارغة.
بالمثل، يمكنك استخدام الأسلوب Worksheet::Validations::GetValidationInCell للحصول على التحقق المطبق على خلية عن طريق توفير مؤشرات الصف والعمود الخاصة بها.
رمز C++ للحصول على التحقق المطبق على خلية
يعرض لك رمز العينة التالي كيفية الحصول على التحقق المطبق على خلية.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Instantiate the workbook from sample Excel file
Workbook workbook(srcDir + u"sample.xlsx");
// Access its first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Cell C1 has the Decimal Validation applied on it. It can take only the values Between 10 and 20
Cell cell = worksheet.GetCells().Get(u"C1");
// Access the validation applied on this cell
Validation validation = cell.GetValidation();
// Read various properties of the validation
std::cout << "Reading Properties of Validation" << std::endl;
std::cout << "--------------------------------" << std::endl;
std::cout << "Type: " << static_cast<int>(validation.GetType()) << std::endl;
std::cout << "Operator: " << static_cast<int>(validation.GetOperator()) << std::endl;
std::cout << "Formula1: " << validation.GetFormula1().ToUtf8() << std::endl;
std::cout << "Formula2: " << validation.GetFormula2().ToUtf8() << std::endl;
std::cout << "Ignore blank: " << validation.GetIgnoreBlank() << std::endl;
Aspose::Cells::Cleanup();
return 0;
}