title: Write data into Excel sheet java
body: <p>I have 3 lists namely list1, list2 and list3. And I want to display these lists in an excel sheet as 3 columns. For example the values in list 1 should be displayed in the first column of Excel sheet. I am adding all the 3 lists to a final list as below and able to display them as separate rows and no idea how can i display as columns. I am using apachepoi.</p>
  
  <pre><code>List&lt;List&gt; finalList = new ArrayList&lt;List&gt;();
       finalList .add(list1);
       finalList .add(list2);
   WritingToExcelFile(List&lt;List&gt; l1) throws Exception {  //passing finalList here
      try {
          for (int j = 0; j &lt; l1.size(); j++) {
              Row row = firstSheet.createRow(rownum);
              List&lt;String&gt; l2 = l1.get(j);
              for (int k = 0; k &lt; l2.size(); k++) {
                  Cell cell = row.createCell(k);
                  cell.setCellValue(l2.get(k));
              }
              rownum++;
          }
      } catch (Exception e) {
          e.printStackTrace();
      } finally {
      }
  }
  </code></pre>