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.
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;