Free Support Forum - aspose.com

executeWithRegions Method not Found using Coldfusion

Hi,


I did a search and could not find a post related to this. I am using Coldfusion 8 and having some problem with the method ‘executeWithRegions’.This is my code:

<cfset mergeDoc=CreateObject(“java”, “com.aspose.words.Document”).init(“C:\mailRegions.docx”)>
SELECT col1, col2, col3
FROM SampleTable
<cfset mergeDoc.getMailMerge().executeWithRegions(“SampleTable”, qryTest)>

I got the following error while running the above code:

Error: The executeWithRegions method was not found.

Detail: Either there are no methods with the specified method name and argument types, or the executeWithRegions method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that matched the provided arguments. If this is a Java object and you verified that the method exists, you may need to use the javacast function to reduce ambiguity.

Anyone experienced something like this?
Hi Eric,

Thanks for your inquiry.

Perhaps you're using an older version of Aspose.Words; I would suggest you please upgrade to the latest version of Aspose.Words. You can download it from the following link:
http://www.aspose.com/community/files/72/java-components/aspose.words-for-java/entry435077.aspx

Moreover, please check the code example "Mail Merge with Regions" from following documentation link. I hope this will helps you.
http://www.aspose.com/docs/display/wordsjava/ColdFusion+and+Aspose.Words+for+Java

Hi Tahir,


Thanks for the reply. I updated the jdk file but still could not get it to work. I followed the instruction on how to do the regions in Coldfusion, but my question is do I really have to create the .jar file to get the dataset? If I am not mistaken the cfquery already returns the result set, so I can use the cfquery as the parameter in the executeWithRegions method. Also how many parameters should be passed to the executeWithRegions method? In the Coldfusion example (http://www.aspose.com/docs/display/wordsjava/ColdFusion+and+Aspose.Words+for+Java) it passes two parameters but in the documentation (http://www.aspose.com/docs/display/wordsjava/MailMerge) it only accepts one parameter. Can anyone help me on this?

Thanks a lot!
Eric

Hi Eric,


Thanks for inquiry. I am working work over your query and will update you asap.

Hi Eric,


Please accept my apologies for late response.
ericyu:
In the Coldfusion example (http://www.aspose.com/docs/display/wordsjava/ColdFusion+and+Aspose.Words+for+Java) it passes two parameters but in the documentation (http://www.aspose.com/docs/display/wordsjava/MailMerge) it only accepts one parameter.
The ColdFusion example in the documentation is not according to latest version of Aspose.Words for Java. We will update this code example as soon as possible. We apologize for your inconvenience.

The latest version of Aspose.Words for Java use one parameter for executeWithRegions method. Please see the details from following documentation link:
http://www.aspose.com/docs/display/wordsjava/MailMerge

In your case, you may pass DataTable or DataSet object to executeWithRegions method to achieve your requirements. Please create a separate Java class for MailMerge with some methods which returns DataTable/DataSet object. The executeWithRegions take parameter of type com.aspose.words.DataTable/com.aspose.words.DataSet which cfquery do not return.

Following Java code example shows the detail of com.aspose.words.DataTable.

<span lang=“EN-GB” style=“font-size:10.0pt;font-family:“Courier New”;color:blue;mso-font-kerning:
0pt;mso-no-proof:yes”>public<span lang=“EN-GB” style=“font-size:10.0pt;
font-family:“Courier New”;mso-font-kerning:0pt;mso-no-proof:yes”> void mailMergeImageFromBlob() throws Exception {<o:p></o:p>

Document doc = new Document(getMyDir() + "MailMerge.MergeImage.doc");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // Loads the driver

// Open the database connection.

String connString = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};" +

"DBQ=" + getDatabaseDir() + "Northwind.mdb" + ";UID=Admin";

// DSN-less DB connection.

java.sql.Connection conn = java.sql.DriverManager.getConnection(connString);

// Create and execute a command.

java.sql.Statement statement = conn.createStatement();

java.sql.ResultSet resultSet = statement.executeQuery("SELECT * FROM Employees");

com.aspose.words.DataTable table = new com.aspose.words.DataTable(resultSet, "Employees");

// Perform mail merge.

doc.getMailMerge().executeWithRegions(table);

// Close the database.

conn.close();

doc.save(getMyDir() + "MailMerge.MergeImage Out.doc");

}


Hope this answers your query. Please let us know if you have any more queries.