WordDocumentCreateDataRegion Method |
Namespace: Aceoffix.WordWriter
public DataRegion CreateDataRegion( string NewDataRegionName, DataRegionInsertType InsertType, string RelativeDataRegionName )
Creates a new DataRegion and returns DataRegion object. It's easy to call this method to create, assign and control a new DataRegion before or after the specified DataRegion.
Typically, the RelativeDataRegionName is the existing DataRegion predefined by user in document. In addition, it can also be other two special DataRegions: [HOME] and [END] that are reserved by Aceoffix. Respectively representing the cursor positions of start and end in document, [HOME] and [END] do not need to be defined manually by user.
If the current document is a blank document without any DataRegion, you can use [HOME] and [END] to generate a formatted document with text and images in a blank document.
The following example shows how to call the CreateDataRegion method to create new DataRegion and populate the new DataRegion with the data. The new DataRegion "NewProductName" is located before the DataRegion "ProductName".
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"; wd.OpenDataRegion("ProductName").Value = "Aceoffix"; Aceoffix.WordWriter.DataRegion drNewProduct = wd.CreateDataRegion("NewProductName", Aceoffix.WordWriter.DataRegionInsertType.Before, "ProductName"); drNewProduct.Value = "Aceoffix for Android"; AceoffixCtrl1.ServerPage = "aceoffix-runtime/server.aspx"; AceoffixCtrl1.Bind(wd); AceoffixCtrl1.OpenDocument("doc/test.doc", Aceoffix.OpenModeType.docReadOnly, "Tom"); //Open document with read-only.