Free Support Forum - aspose.com

Constructing a DataTable without a ResultSet

Hi, I am evaluating the Words product (latest version 10.1.0.0) for Java and am attempting to do a mail merge with regions, but am having difficulty constructing a DataTable object. This class is missing from the API although it is present in the jar file:
http://www.aspose.com/documentation/java-components/aspose.words-for-java/index.html

In eclipse the only constructor allowed by this class is the one taking a ResultSet, however an example on your site shows a different approach, defining columns and adding rows manually:
http://www.aspose.com/documentation/java-components/aspose.words-for-java/howto-apply-custom-formatting-during-mail-merge.html

DataTable dataTable = new DataTable(“Suppliers”);

dataTable.Columns.Add(“CompanyName”);


dataTable.Columns.Add(“ContactName”);


for (int i = 0; i < 10; i++)


{


DataRow datarow = dataTable.NewRow();


dataTable.Rows.Add(datarow);


datarow[0] = "Company " + Integer.toString(i);


datarow[1] = "Contact " + Integer.toString(i);


}


Further, the DataTable class that I can see does not have Columns and Rows properties. Am I missing something? How do I configure my test app so that I can use DataTable as in this example?

Thanks,
Henry

Hi Henry,

Thanks for your inquiry.

You are correct that these are errors in the code, there are no methods for the implementation of DataTable in Java. The reason for these errors is because we have just made the sample code from .NET autoportable to Java. However some projects may have errors like these which cause them not work.

I am in the process of updating each sample so they all work, in the mean time I think it would be easiest for you to achieve this same technique in your application if you retrieve your data from a database into a ResultSet as standard. The ResultSet can be passed to a new DataTable instance and this used to execute mail merge.

If you have any further queries, please feel free to ask.

Thanks,

Hi Adam,

Thanks for clarifying that. I’m not too concerned about the examples - I’ve got my own examples working now - but what does concern me is that even after auto-porting, the Java product still lacks some of the functionality of the .NET product. Is there a list of features that are not supported in Java?

You’ll understand that we’re looking for an enterprise solution and we have little control over which Word features our template documents use (given that they are created by our clients) so I’d like a very clear picture of the scope of the interface.

Regards,
Henry

Hi Henry,

Thanks for your request. Please follow the link to see the list of known issues in Aspose.Words for Java:

http://www.aspose.com/documentation/java-components/aspose.words-for-java/known-issues-in-aspose-words-for-java.html

You are right; some of features are not yet implemented in Java. For example rendering documents to images and printing.

Best regards,