22using Syncfusion . DocIO . DLS ;
33
44//Loads an existing Word document into DocIO instance.
5- WordDocument document = new WordDocument ( @"../../../Data/Template.docx" ) ;
6- IWSection sec = document . LastSection ;
7- WTextFormField textFF ;
8- WDropDownFormField dropFF ;
5+ using ( WordDocument document = new WordDocument ( @"../../../Data/Template.docx" ) )
6+ {
7+ IWSection sec = document . LastSection ;
8+ WTextFormField textFF ;
9+ WDropDownFormField dropFF ;
910
10- //Access the form field with field name
11- textFF = sec . Body . FormFields [ "FullName" ] as WTextFormField ;
11+ //Access the form field with field name
12+ textFF = sec . Body . FormFields [ "FullName" ] as WTextFormField ;
1213
13- //Fill value for the textfield
14- textFF . TextRange . Text = "John" ;
14+ //Fill value for the textfield
15+ textFF . TextRange . Text = "John" ;
1516
16- //Access the form field with field name
17- textFF = sec . Body . FormFields [ "BirthDayField" ] as WTextFormField ;
18- textFF . TextRange . Text = "5.13.1980" ;
17+ //Access the form field with field name
18+ textFF = sec . Body . FormFields [ "BirthDayField" ] as WTextFormField ;
19+ textFF . TextRange . Text = "5.13.1980" ;
1920
20- //Access the form field with index
21- textFF = sec . Body . FormFields [ 2 ] as WTextFormField ;
22- textFF . TextRange . Text = "221b Baker Street" ;
21+ //Access the form field with index
22+ textFF = sec . Body . FormFields [ 2 ] as WTextFormField ;
23+ textFF . TextRange . Text = "221b Baker Street" ;
2324
24- textFF = sec . Body . FormFields [ 3 ] as WTextFormField ;
25- textFF . TextRange . Text = "(206)555-3412" ;
25+ textFF = sec . Body . FormFields [ 3 ] as WTextFormField ;
26+ textFF . TextRange . Text = "(206)555-3412" ;
2627
27- textFF = sec . Body . FormFields [ 4 ] as WTextFormField ;
28- textFF . TextRange . Text = "John@company.com" ;
28+ textFF = sec . Body . FormFields [ 4 ] as WTextFormField ;
29+ textFF . TextRange . Text = "John@company.com" ;
2930
30- dropFF = sec . Body . FormFields [ 5 ] as WDropDownFormField ;
31+ dropFF = sec . Body . FormFields [ 5 ] as WDropDownFormField ;
3132
32- //Set the value
33- dropFF . DropDownSelectedIndex = 1 ;
33+ //Set the value
34+ dropFF . DropDownSelectedIndex = 1 ;
3435
35- textFF = sec . Body . FormFields [ 6 ] as WTextFormField ;
36- textFF . TextRange . Text = "Michigan University" ;
36+ textFF = sec . Body . FormFields [ 6 ] as WTextFormField ;
37+ textFF . TextRange . Text = "Michigan University" ;
3738
38- dropFF = sec . Body . FormFields [ 7 ] as WDropDownFormField ;
39- dropFF . DropDownSelectedIndex = 1 ;
39+ dropFF = sec . Body . FormFields [ 7 ] as WDropDownFormField ;
40+ dropFF . DropDownSelectedIndex = 1 ;
4041
41- dropFF = sec . Body . FormFields [ 8 ] as WDropDownFormField ;
42- dropFF . DropDownSelectedIndex = 2 ;
42+ dropFF = sec . Body . FormFields [ 8 ] as WDropDownFormField ;
43+ dropFF . DropDownSelectedIndex = 2 ;
4344
44- //Saving the document as .docx
45- document . Save ( @"../../../Output/Sample.docx" , FormatType . Docx ) ;
46- //Closes the document instance.
47- document . Close ( ) ;
45+ //Saving the document as .docx
46+ document . Save ( @"../../../Output/Sample.docx" , FormatType . Docx ) ;
47+ }
0 commit comments