ค้นหาคุณสมบัติของฟิลด์
ช่องที่แทรกโดยใช้ DocumentBuilder.InsertField จะส่งกลับออบเจ็กต์ Field นี่คือคลาสส่วนหน้าที่ให้วิธีการที่เป็นประโยชน์ในการค้นหาคุณสมบัติบางอย่างของฟิลด์อย่างรวดเร็ว
ตัวอย่างโค้ดต่อไปนี้แสดงวิธีการค้นหาโค้ดฟิลด์และผลลัพธ์ของฟิลด์:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET | |
Document doc = new Document(MyDir + "Hyperlinks.docx"); | |
foreach (Field field in doc.Range.Fields) | |
{ | |
string fieldCode = field.GetFieldCode(); | |
string fieldResult = field.Result; | |
} |
โปรดทราบว่าหากคุณกำลังมองหาเพียงชื่อของช่องผสานในเอกสาร คุณสามารถใช้วิธี GetFieldNames ในตัวแทนได้
ตัวอย่างโค้ดต่อไปนี้แสดงวิธีรับชื่อของเขตข้อมูลผสานทั้งหมดในเอกสาร:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET | |
Document doc = new Document(); | |
string[] fieldNames = doc.MailMerge.GetFieldNames(); |