Tags and table

Hi,
I’m currently evaluating the Java Aspose.Words and very impressed with its capabilities.
Have two questions:

  1. How can Word Tags values be updated from an existing template?
  2. 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;
}

Hi luc,
Thanks for your inquiry. Please accept my apology for delayed response, as we were in middle of some other queries. Now I am working on your request and update you soon.
Best Regards,.

Hi luc,
Thanks for patience. Please find below the answers of your questions. Hopefully it will fulfill your requirements.

  1. How can Word Tags values be updated from an existing template?
    StructuredDocumentTag class method and properties are used to manipulate Word Tags.Please refere to attached code.
  2. 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

You can achieve Multiline values insertion in template by using Mail Merge with regions feature of Aspose.Words. You can use ResultSet object as a data source for the requirements.

Kindly refer to attached output file and code for solution. Please feel free to contact us for any further query.
Regards