|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.acesoft.aceoffix.wordwriter.WordDocument
public class WordDocument
Representing a Word document, WordDocument class is used to output data to the Word document dynamically and control the format and the editing of the document.
WordDocument is an important class. WordDocument object is the data source of AceoffixCtrl and used as the parameter of the AceoffixCtrl.bind method or the FileMakerCtrl.bind method. WordDocument class is used to dynamically output the data to the Word document and control the format and the editing of the document.
Constructor Summary | |
---|---|
WordDocument()
Initializes a new instance of WordDocument class. |
Method Summary | |
---|---|
DataRegion |
createDataRegion(java.lang.String newDataRegionName,
DataRegionInsertType insertType,
java.lang.String relativeDataRegionName)
Creates a new DataRegion and returns a DataRegion object. |
Template |
getTemplate()
Gets a Template object. |
WaterMark |
getWaterMark()
Gets a WaterMark object. |
void |
insertPageBreak()
Inserts Page Break at the current cursor. |
DataRegion |
openDataRegion(java.lang.String dataRegionName)
Opens the specified DataRegion and returns a DataRegion object. |
DataTag |
openDataTag(java.lang.String dataTagName)
Opens the specified DataTag and returns a DataTag object. |
void |
setDisableWindowDoubleClick(boolean disableWindowDoubleClick)
Sets a value that indicates whether double-click is disabled in current document. |
void |
setDisableWindowRightClick(boolean disableWindowRightClick)
Sets a value that indicates whether right-click is disabled in current document. |
void |
setDisableWindowSelection(boolean disableWindowSelection)
Sets a value that indicates whether selection is disabled in current document. |
void |
setEnableAllDataRegionsEditing(boolean enableAllDataRegionsEditing)
Sets a value that indicates whether all the DataRegions in document are editable. |
java.lang.String |
toString(java.lang.String enc)
Gets a class name. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WordDocument() throws java.lang.Exception, java.io.IOException
java.lang.Exception
java.io.IOException
Method Detail |
---|
public void setDisableWindowDoubleClick(boolean disableWindowDoubleClick)
disableWindowDoubleClick
- The default value is false.public void setDisableWindowRightClick(boolean disableWindowRightClick)
disableWindowRightClick
- The default value is false.public void setDisableWindowSelection(boolean disableWindowSelection)
disableWindowSelection
- The default value is false.public void setEnableAllDataRegionsEditing(boolean enableAllDataRegionsEditing)
enableAllDataRegionsEditing
- The default value is false.public WaterMark getWaterMark()
public Template getTemplate()
public java.lang.String toString(java.lang.String enc) throws java.io.IOException
java.io.IOException
public DataRegion openDataRegion(java.lang.String dataRegionName) throws java.lang.Exception, java.io.IOException
The following examples show how to use the SaveDataPage property.
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.
AceoffixCtrl aceCtrl1 = new AceoffixCtrl(request); aceCtrl1.setServerPage("server.ace"); // Required WordDocument wd = new WordDocument(); wd.openDataRegion("CompanyName").setValue("Acesoft"); wd.openDataRegion("ProductName").setValue("Aceoffix"); aceCtrl1.bind(wd); aceCtrl1.openDocument("doc/test.doc", OpenModeType.docReadOnly, "Tom"); aceCtrl1.setTagId("AceoffixCtrl1"); // Required
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 AceoffixCtrl.JsFunction_OnWordDataRegionClickevent. 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.
AceoffixCtrl aceCtrl1 = new AceoffixCtrl(request); aceCtrl1.setServerPage("server.ace"); // Required WordDocument wd = new WordDocument(); DataRegion dataRegion = wd.openDataRegion("CompanyName"); dataRegion.setValue("Acesoft");// Sets initial value dataRegion.setEditing(true);// Users are allowed to input. wd.openDataRegion("ProductName").setEditing(true);// Users are allowed to input. aceCtrl1.bind(wd); aceCtrl1.setSaveDataPage("savedata.jsp"); aceCtrl1.setJsFunction_OnWordDataRegionClick("OnWordDataRegionClick()"); aceCtrl1.openDocument("doc/test.doc", OpenModeType.docSubmitForm, "Tom"); aceCtrl1.setTagId("AceoffixCtrl1"); // Required
dataRegionName
- The name of DataRegion.
java.lang.Exception
java.io.IOException
com.acesoft.aceoffix.wordreader.WordDocument.openDataRegion() to learn how to get the values of these DataRegions when saving the document.
public DataRegion createDataRegion(java.lang.String newDataRegionName, DataRegionInsertType insertType, java.lang.String relativeDataRegionName) throws java.lang.Exception, java.io.IOException
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.
AceoffixCtrl aceCtrl1 = new AceoffixCtrl(request); aceCtrl1.setServerPage("server.ace"); // Required WordDocument wd = new WordDocument(); wd.openDataRegion("CompanyName").setValue("Acesoft"); wd.openDataRegion("ProductName").setValue("Aceoffix"); DataRegion drNewProduct = wd.createDataRegion("NewProductName", DataRegionInsertType.Before, "ProductName"); drNewProduct.setValue("Aceoffix for Android"); aceCtrl1.bind(wd); aceCtrl1.openDocument("doc/test.doc", OpenModeType.docReadOnly, "Tom"); //Open document with read-only. aceCtrl1.setTagId("AceoffixCtrl1"); // Required
newDataRegionName
- The name of new DataRegion. Note: The name should be different from that of the existing DataRegions in the document.insertType
- The insert type of the new DataRegion.relativeDataRegionName
- The name of the relative DataRegion.
java.lang.Exception
java.io.IOException
public DataTag openDataTag(java.lang.String dataTagName) throws java.lang.Exception, java.io.IOException
The DataTag object represents all the text area matched with the specified pattern string in Word document.
The following example shows how to call the OpenDataTag method to open DataTag and fill data into the specified location of Word document.
Before running the code, please make sure that you have inserted pattern string "{CompanyName}"and "{ProductName}" into the test.doc.
AceoffixCtrl aceCtrl1 = new AceoffixCtrl(request); aceCtrl1.setServerPage("server.ace"); // Required WordDocument wd = new WordDocument(); wd.openDataTag("{CompanyName}").setValue("Acesoft"); wd.openDataTag("{ProductName}").setValue("Aceoffix"); aceCtrl1.bind(wd); aceCtrl1.openDocument("doc/test.doc", OpenModeType.docReadOnly, "Tom"); aceCtrl1.setTagId("AceoffixCtrl1"); // Required
dataTagName
- The name of the DataTag is the pattern string defined by user in Word document.
java.lang.Exception
java.io.IOException
public void insertPageBreak() throws java.lang.Exception, java.io.IOException
java.lang.Exception
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |