Generate Excel file From Tjava component

Four Stars

Generate Excel file From Tjava component

Want to generate excel file from tjava componnet contains Arraylist of headers , List of hashmap for data of excel file 

 

tjava component is as follows :

 

List<String> headers = new ArrayList<String>();
headers.add("header1");
headers.add("header2");
headers.add("header3");

List<HashMap<String, String>> rows = new ArrayList<HashMap<String,String>>();

HashMap<String, String> row1 = new HashMap<String, String>();
row1.put("Header1","abc");
row1.put("header2","10");
row1.put("header3", "xyz");

rows.add(row1);

HashMap<String, String> row2 = new HashMap<String, String>();
row1.put("Header1","abcABC");
row1.put("header2","1010");
row1.put("header3", "xyzXYZ");

rows.add(row2);
this.globalMap.put("headres", headers);
this.globalMap.put("rows", rows);

 

need to create excel file as follows

 

Header1  Header2 Header3

abc             10          xyz

abcABC       1010   xyzXYZ

Sixteen Stars

Re: Generate Excel file From Tjava component

Use a tJavaFlex for this. Prepare your data in the Start Code section. Open a loop in the Start Code (for or while). Then you can send your row data to your XML component in the Main Code section. The Main Code section is called once for every loop iteration. You can use that to go through your ArrayList and pass the values to your output row. In your End Code section, simply close the loop and carry out any tidy up code.