מצא מאפייני שדה
שדה שמוכנס באמצעות 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(); |