Tuesday, June 16, 2009


To those who don't know, jXls is a welcome java tool (read library), for easy conversion of raw data into an excel file. Nice tool and simple to use.

One thing to take care of while using this is not to use same names for the key in your map as present in the Object fieldName or part of the fieldname.
If present, the result does not print those particular fields in the excel sheet

For those who are unclear
We were sending customer data combined with the address data for the customer. Doing something like:

private List customerL = new ArrayList();
private List addressL = new ArrayList();

private void createLists()
// Add all that you want to the lists.

private void createCustomerFile(Map beans, XLSTransformer transformer) throws IOException
beans.put("customer", this.customerL);
beans.put("address", this.addressL); transformer.transformXLS(this.configM.get("CUSTOMER_XLS_TEMPLATE"), beans, (FOLDER_NAME + "/" + "Customer.xls")); beans.remove("customer");

My excel sample file contains fields like name, id, loginId, hobbies, customerClass [these come from customer record] and address, city, pincoce [these come from address record].

In this case the customerClass and the address fields were not populated in the result excel sheet.

The solution: simple change the Map keys: customer to customerRecord and address to addressRecord.

All solved.

For more information on jXls pleas visit: http://jxls.sourceforge.net/index.html

No comments :