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

Free Support Forum - aspose.com

.doc - .docx issue while doing merge by using java

I am able to merge the document when the my template extension is .doc . But when i am trying to do the merge with the .docx extension template i am getting format not supported. Can you please check into this issue. I am saving the document by using the MS MICROSOFT WORD.

I am not changing the extensions of the template. I am properly saving the file with the different formats and with proper extension.


Version which I am using is Aspose.words.jdk15.jar

Code is as follows:

import java.io.File;

import java.net.URI;


import com.aspose.words.Document;

import com.aspose.words.DocumentBuilder;



/**

* This sample shows how to insert check boxes and text input form fields during mail merge into a document.

*/

class Program

{

/**

* The main entry point for the application.

*/

public static void main(String[] args) throws Exception

{

Program program = new Program();

program.execute();

}


private void execute() throws Exception

{


URI exeDir = Program.class.getResource("").toURI();

String dataDir = new File("/Users/chandan/var/emdtdata/patientfiles/templates") + File.separator;


// Load the template document.

//Document doc = new Document("/Users/chandan/var/emdtdata/patientfiles/templates/eMDT_Example letter template to whom it may concern1.doc");

Document doc = new Document("/Users/chandan/var/emdtdata/patientfiles/templates/forename.docx");

String[] fieldNames = new String[] {"forename", "surname", "dateOfBirth", "hospitalNumber",

"MeetingDate", "MeetingDate1", "MDMRecSurgery", "MDMSurgeryType", "MDMRecChemo","MDMOncologist","MDMChemoType"};

Object[] fieldValues = new Object[] {"forename1", "surname1", "dateOfBirth1", "hospitalNumber1",

"MeetingDate1", "MeetingDate11", "MDMRecSurgery1", "MDMSurgeryType1", "MDMRecChemo1","MDMOncologist1","MDMChemoType1"};


// Execute the mail merge.

doc.getMailMerge().execute(fieldNames, fieldValues);


// Save the finished document.

doc.save(dataDir + "Template Out6.docx");

}




private DocumentBuilder mBuilder;

}

Hi there,

Thanks for your inquiry. Could you please attach your input Word document here for testing? I will investigate the issue on my side and provide you more information.