البحث عن خصائص الحقل

Contents
[ ]

حقل يتم إدراجه باستخدام DocumentBuilder.InsertField إرجاع كائن Field. هذه فئة واجهة توفر طرقا مفيدة للعثور بسرعة على بعض خصائص الحقل.

يوضح مثال التعليمات البرمجية التالية كيفية العثور على رمز الحقل والنتيجة الميدانية:

//For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C
auto doc = MakeObject<Document>(MyDir + "Hyperlinks.docx");
for(const auto& field : doc->get_Range()->get_Fields())
{
auto fieldCode = field->GetFieldCode();
auto fieldResult = field->get_Result();
}

ملاحظة إذا كنت تبحث فقط عن أسماء حقول الدمج في مستند، فيمكنك بدلا من ذلك استخدام طريقة GetFieldNames المضمنة.

يوضح مثال الكود التالي كيفية الحصول على أسماء جميع حقول الدمج في مستند:

//For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C
auto doc = MakeObject<Document>();
ArrayPtr<String> fieldNames = doc->get_MailMerge()->GetFieldNames();