title: Java List to Excel Columns
body: <p>Correct me where I'm going wrong. </p>
  
  <p>I'm have written a program in Java which will get list of files from two different directories and make two (Java list) with the file names. I want to transfer the both the list (downloaded files list and Uploaded files list) to an excel. </p>
  
  <p>What the result i'm getting is those list are transferred row wise. I want them in column wise.</p>
  
  <p>Given below is the code:</p>
  
  <pre><code>    public class F {
  
  static List&lt;String&gt; downloadList = new ArrayList&lt;&gt;();
  static List&lt;String&gt; dispatchList = new ArrayList&lt;&gt;();
  
  public static class FileVisitor extends SimpleFileVisitor&lt;Path&gt; {
  
      @Override
      public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
          String name = file.toRealPath().getFileName().toString();
          if (name.endsWith(".pdf") || name.endsWith(".zip")) {
              downloadList.add(name);
          }
          if (name.endsWith(".xml")) {
              dispatchList.add(name);
          }
          return FileVisitResult.CONTINUE;
      }
  }
  
  public static void main(String[] args) throws IOException {
      try {
          Path downloadPath = Paths.get("E:\\report\\02_Download\\10252013");
          Path dispatchPath = Paths.get("E:\\report\\01_Dispatch\\10252013");
  
          FileVisitor visitor = new FileVisitor();
          Files.walkFileTree(downloadPath, visitor);
          Files.walkFileTree(downloadPath, EnumSet.of(FileVisitOption.FOLLOW_LINKS), 1, visitor);
  
          Files.walkFileTree(dispatchPath, visitor);
          Files.walkFileTree(dispatchPath, EnumSet.of(FileVisitOption.FOLLOW_LINKS), 1, visitor);
          System.out.println("Download File List" + downloadList);
          System.out.println("Dispatch File List" + dispatchList);
          F f = new F();
          f.UpDown(downloadList, dispatchList);
      } catch (Exception ex) {
          Logger.getLogger(F.class.getName()).log(Level.SEVERE, null, ex);
      }
  
  }
  int rownum = 0;
  int colnum = 0;
  HSSFSheet firstSheet;
  Collection&lt;File&gt; files;
  HSSFWorkbook workbook;
  File exactFile;
  
  {
      workbook = new HSSFWorkbook();
      firstSheet = workbook.createSheet("10252013");
      Row headerRow = firstSheet.createRow(rownum);
      headerRow.setHeightInPoints(40);
  }
  
  public void UpDown(List&lt;String&gt; download, List&lt;String&gt; upload) throws Exception {
  
      List&lt;String&gt; headerRow = new ArrayList&lt;&gt;();
      headerRow.add("Downloaded");
      headerRow.add("Uploaded");
      List&lt;List&gt; recordToAdd = new ArrayList&lt;&gt;();
  
      recordToAdd.add(headerRow);
      recordToAdd.add(download);
      recordToAdd.add(upload);
      F f = new F();
      f.CreateExcelFile(recordToAdd);
      f.createExcelFile();
  }
  
  void createExcelFile() {
      FileOutputStream fos = null;
      try {
          fos = new FileOutputStream(new File("E:\\report\\Download&amp;Upload.xls"));
          HSSFCellStyle hsfstyle = workbook.createCellStyle();
          hsfstyle.setBorderBottom((short) 1);
          hsfstyle.setFillBackgroundColor((short) 245);
          workbook.write(fos);
      } catch (Exception e) {
      }
  }
  
  public void CreateExcelFile(List&lt;List&gt; l1) throws Exception {
      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) {
      } finally {
      }
  }
      }
  </code></pre>
  
  <p>(The purpose is to verify the files Downloaded and Uploaded for the given date)
  Thanks.</p>