We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem with mailmerge with java connector 5.1.3x

Hi,

I've detected an issue with mailmerge when i use mysql-connector 5.1.3x.
Indeed, fields are not replaced in template with these connector version, while the same operation is well processed with 3.0.16 connector version.
Do you know this issue ?
Have you a workaround ?
What can i do ?

I attach a project example and files results.

It should missing a library called "converter" which is only an aspose converter from docx to pdf.

Regards,
Christophe

Hi Christophe,

Looks like field names in template are not matching with the field names in data. Please follow http://www.aspose.com/docs/display/wordsjava/How+to++Apply+Custom+Formatting+during+Mail+Merge to check the field names coming from the database.

Please also share the data in XML format for further analysis.

Best Regards,

Hi Muhammad,


However i have no problems when I use the same code with the java connector 3.0.16.
Did you try this example with the two connectors ?
Is mailmerge can work with the connector 5.1.3x ?

I attach datas in XML format.

Regards,
Christophe

Hi Christophe,

Aspose.Words does not directly connect to MySQL so there is no issue of connectors with Aspose.Words. It uses offline data sources (DataTable and XML etc.) . Table and field names in the offline data source should match the table and merge field names in the Word template.

I get correct output when I use matching fields with your XML data however there are multiple templates and XMLs in the samples you have shared and it is not clear which XML is used with which Word template; field names in XML are also not matching the field names in the template.

Can you please share a single Word template and matching XML data to reproduce the issue?

Best Regards,

Hi,


I don’t use XML data but data from a database.
In my code, data are provided to the DataTable by SQL request in a ResultSet to be merged with Word document, as mentioned in this example :

http://www.aspose.com/docs/display/wordsjava/How+to++Execute+Mail+Merge+with+Regions

If you look at the JobMailMerger class, all this mecanism is implemented in method merge.

In this SQL request, fields are aliased by the Word template field name

SELECT
j.id as job_id,
jt.jobtitle as job_title,
j.pagecount as job_pagecount,
jt.copycount as job_copycount,

I attach the main Word template used, SQL database export and request used.

Regards,
Christophe

Hi Christophe,

The template attached to your post does not have any table (TableStart and TableEnd merge fields) so executeWithRegions will not work in this case. You need to execute simple mail merge in this case.

As far as tabular data is concerned, we will update your template to handle tabular data according to your SQL and share updated example with you soon.

Best Regards,

Hi Muhammad,


I use templateBATLetter.docx (supplied in project ) for ‘with region’ implementation.
But, I don’t think that is the problem.

As I wrote earlier, this project can run correctly as it is with a previous version of java connector for mysql.

If you look at the project I attach, I supplied two templates : one with region and one other without region.
And the code is able to use the two, according to the part of code commented.
So, I can use “without region” by using “templateBATLetterWithoutRegions.docx” Word template and by calling convertWordToPdf(simpleMergeDocument(… in createBatLetter of MailFactory class.
To use “with region”, I define BAT_LETTER_TEMPLATE_NAME= templateBATLetter.docx and call convertWordToPdf(mergeWordDocumentWithData(… in this case.

Best regards,
Christophe

Hi Christophe,

We are working on this issue and will update you soon.

Best Regards,