Hi,
I’m currently evaluating the Java Aspose.Words and very impressed with its capabilities.
Have two questions:
- How can Word Tags values be updated from an existing template?
- How to insert multiline values in an existing table from a word template? The data is not from a database query. The values will be read from a Java table and then merged or inserted into a word table.
Please refer to code below and word attachments. Templates were created with Word 2010.
Thanks very much for your support,
LMJ
private int FillWordTemplate()
{
Document doc = null;
try
{
com.aspose.words.License license = new com.aspose.words.License();
license.setLicense("C:\\Dev\\Aspose.Total.Java.lic");
doc = new Document("C:\\Dev\\WordTemplate.docx");
}
catch (Exception e)
{
e.printStackTrace();
}
int type = doc.getNodeType();
Node tags[] = doc.getChildNodes(NodeType.STRUCTURED_DOCUMENT_TAG, true).toArray();
// The tag "nametag" from the word template can be accessed via the above function.
// "nametag" is a word combo box and has the following values: "Poor", "Good" and "Excellent"
// How can one of these values be set programmatically ?
try
{
// works
doc.getMailMerge().execute(new String[] { "Title", "Doctor", "Therapist", "Client" }, new Object[] { "My report", "John Doe", "My name", "Mrs. Ann Who" });
// Does not work and cannot use data from a database query. The values will be read from a Java table and then merged or inserted with a word table.
// Is there another way to insert multiline values in an existing table word template?
Object[][] invoicedata = { { "APAP1", "Frank1" }, { "APAP2", "Frank2" } };
doc.getMailMerge().execute(new String[] { "column1", "column2" }, invoicedata);
doc.save("C:\\Dev\\WordTemplateWithData.docx");
}
catch (Exception e)
{
e.printStackTrace();
}
return 0;
}