WordDocumentOpenDataRegion Method |
Namespace: Aceoffix.WordWriter
Opens the specified DataRegion and returns a DataRegion object.
Code example 1:The following code example shows how to call the OpenDataRegion method to open DataRegion and fill data into the specified location of Word document.
Before running the code, please make sure that you have inserted the bookmark "ACE_CompanyName" and the bookmark "ACE_ProductName" into the test.doc.
Aceoffix.WordWriter.WordDocument wd = new Aceoffix.WordWriter.WordDocument(); wd.DisableWindowSelection = true; wd.DisableWindowRightClick = true; wd.OpenDataRegion("CompanyName").Value = "Acesoft"; wd.OpenDataRegion("ProductName").Value = "Aceoffix"; AceoffixCtrl1.ServerPage = "aceoffix-runtime/server.aspx"; AceoffixCtrl1.Bind(wd); AceoffixCtrl1.OpenDocument("doc/test.doc", Aceoffix.OpenModeType.docReadOnly, "Tom");
Code example 2:The following example shows how to set OpenModeType as docSumitForm and set the editable DataRegions within Word document. By running this code, user can only edit text in range specified by the "CompanyName" DataRegion and the "ProductName" DataRegion. Besides those editable ranges, the Word document is read-only.
If you want that your users can only input the specified values, you can define the JsFunction_OnWordDataRegionClick event. The event is used to trigger a select dialog box when user click the DataRegion.
Before running the code, please make sure that you have inserted the bookmark "ACE_CompanyName" and the bookmark "ACE_ProductName" into the test.doc.
Aceoffix.WordWriter.WordDocument wd = new Aceoffix.WordWriter.WordDocument(); wd.OpenDataRegion("CompanyName").Value = "Acesoft"; //Sets initial value wd.OpenDataRegion("CompanyName").Editing = true; wd.OpenDataRegion("ProductName").Editing = true; AceoffixCtrl1.ServerPage = "aceoffix-runtime/server.aspx"; AceoffixCtrl1.Bind(wd); AceoffixCtrl1.SaveDataPage = "savedata.aspx"; AceoffixCtrl1.JsFunction_OnWordDataRegionClick = "OnWordDataRegionClick()"; AceoffixCtrl1.OpenDocument("doc/test.doc", Aceoffix.OpenModeType.docSubmitForm, "Tom");