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

Free Support Forum - aspose.com

Mailmerge merges object ID instead of value


I am facing yet another problem, this time performing a simple mail merge.

There problem is, the resulting document after the mail merge operation contains some fields which seem to have been replaced by the java “object ID” or something similar, instead of the actual value.

I have attached both my template.doc and result.doc.

The problem seems to be happening for three fields named massima_quantita_deposito, periodicita_carico and periodicita_scarico.

All the data is taken from a MySQL 5.1 database through this query:

SELECT t1.*, IFNULL(t1.rifiuto, ‘===’) as rifiuto,
IFNULL(t1.destino, ‘===’) as destino,
IFNULL(t1.rifiuto, ‘===’) as rifiuto,
IFNULL(t1.stato_fisico, ‘===’) as stato_fisico,
IFNULL(t1.nome_responsabile, ‘===’) as nome_responsabile,
IFNULL(t1.descrizione, ‘===’) as descrizione,
IFNULL(t1.materie_prime, ‘===’) as materie_prime,
IFNULL(t1.contenitore, ‘===’) as contenitore,
IFNULL(t1.deposito, ‘===’) as deposito,
IF(t1.data_ultima_analisi IS NULL, ‘===’, DATE_FORMAT(t1.data_ultima_analisi, ‘%d-%m-%Y’)) as data_ultima_analisi,
IF(t1.quantita_deposito > 0, CONCAT(t1.quantita_deposito, ’ ', t1.unita_misura), ‘===’) as massima_quantita_deposito,
IF(t1.carico_periodicita_num > 0, CONCAT('ogni ', t1.carico_periodicita_num, ’ ', get_periodicita_tipo(t1.carico_periodicita_tipo)), ‘===’) as periodicita_carico,
IF(t1.scarico_periodicita_num > 0, CONCAT('ogni ', t1.scarico_periodicita_num, ’ ', get_periodicita_tipo(t1.scarico_periodicita_tipo)), ‘===’) as periodicita_scarico,
t2.codice as codice_cer,
t2.descrizione as descrizione_cer,
IF(t1.destino = ‘Smaltimento’, CONCAT(t4.smaltimento, ’ - ', t4.codice),
IF(t1.destino = ‘Recupero’, CONCAT(t3.recupero, ’ - ', t3.codice), ‘===’)) as destino_operazione,
IFNULL(GROUP_CONCAT(DISTINCT CONCAT(t6.codice, ’ - ', t6.pericolo) ORDER BY t6.pericolo SEPARATOR ‘\n’), ‘===’) as classi_pericolo,
IFNULL(GROUP_CONCAT(DISTINCT t8.nome_area_lavoro ORDER BY t8.nome_area_lavoro SEPARATOR ‘\n’), ‘===’) as processi
FROM lin_98_47_rifiuti as t1
JOIN agews_rifiuti_cer as t2 USING(id_codice)
LEFT JOIN agews_rifiuti_recupero as t3 USING(id_recupero)
LEFT JOIN agews_rifiuti_smaltimento as t4 USING(id_smaltimento)
LEFT JOIN lin_98_47_pericolo as t5 USING(id_rifiuto, id_azienda, id_sede, revisione_documento)
LEFT JOIN agews_rifiuti_pericolo as t6 USING(id_pericolo)
LEFT JOIN lin_98_47_processi as t7 USING(id_rifiuto, id_azienda, id_sede, revisione_documento)
LEFT JOIN gen_12_1_aree_lavoro as t8 USING(id_area_lavoro, id_azienda, id_sede, revisione_documento)
WHERE id_rifiuto = ‘2’ AND id_azienda = ‘3’ AND id_sede = ‘12’ AND revisione_documento = '0’
GROUP BY id_rifiuto

The data returned by the query, together with the table structure, is inside the attached .xml file.

The mailmerge is then done by calling

doc.getMailMerge().execute(new DataTable(rs));

where doc is the Document and rs is the corresponding ResultSet.

Why am I getting such a strange merge? And how can I solve this problem?

By the way, this is just an example, I have similar problem on other templates as well!

I have found a workaround for this issue.

If, in my query, I replace

IF(t1.quantita_deposito > 0, CONCAT(t1.quantita_deposito, ’ ', t1.unita_misura), ‘===’) as massima_quantita_deposito


CONVERT(IF(t1.quantita_deposito > 0, CONCAT(t1.quantita_deposito, ’ ', t1.unita_misura), ‘===’), CHAR) as massima_quantita_deposito

then the result is merged correctly.

Still, I must say I really do not like this, 'cause I find it strange that a mere CONCAT() operation would fail to produce a valid string sometimes, and I am prone to think this is some kind of bug in the Aspose library.

Hi Matteo,

Thanks for your inquiry and sorry for the delayed response. We are checking with this scenario and will get back to you soon.

Best regards,

Hi Matteo,

Thank you for being patient. After an initial test with Aspose.Words 13.4.0, I was unable to reproduce this problem on my side. Could you please give the latest version (13.4.0) a try and see if it resolves your problem? However, this issue sounds like a bug and we will gladly look into fixing it as soon as we can reproduce it on our side. So, please create a simple application (for example a Java Console Application Project) that helps us reproduce the same problem on our end and attach it here for testing. Thanks for your cooperation.

Best regards,

I am already using latest version of Aspose.Words for Java.

I am sorry, but right now we are very busy closing and testing a critical update for our own software, and I really haven’t the time to provide you with a sandboxed test case for this issue, I’ll try and see what can I do in a few days.

Hi Matteo,

Sure, we will wait for you input. We will gladly look into fixing it as soon as we can reproduce it on our side.

Best regards,


I have attached a .zip archive containing the following:
- a template in .doc format
- the .doc result obtained
- a .sql file containing the query to be executed
- a .txt file containing the parameter to connect to our demo database using JDBC drivers

When you get the ResultSet from the query, that is then merged by doing

doc.getMailMerge().execute(new DataTable(ResultSet));

I hope that this helps you reproduce the issue on your side, I haven’t had the time to prepare the java console application, but it should be a trivial task for you now.

Hi Matteo,

Thanks for the additional information. Unfortunately, I was unable to connect/query your database using the credentials you supplied in ‘parameters.txt’ file. I received the following error on my side.

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user ‘Aspose’@’%’ to database 'db_626suiteother’

Also, please find attached the screenshot of the error.

Best regards,
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user 'Aspose'@'%' to database 'db_626suiteother'

Sorry for the late response.

This error is very easy to explain, in fact the database name is db_626suite, as clearly stated in the .txt file I attached, and not db_626suiteother.

You probably read it like that because you opened the .txt file with some editor which did not properly recognize the line ending used.

I am attaching the file againg, hoping that you'll be able to read it properly this time.
Hi Matteo,

Thanks for the additional information. I tested your scenario with the latest version of Aspose.Words for Java 13.5.0 and have managed to reproduce the same problem on my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSJAVA-735. Our development team will further look into the details of this problem and we will keep you updated on the status of correction. We apologize for your inconvenience.

Best regards,

The issues you have found earlier (filed as WORDSJAVA-735) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.