title: Export JTable into Excel file
body: <p>here I am trying to export JTable into excel file...I didn't get any error on console...but on excel sheet I got only column names...my aim is want to show database table in this JTable square, and below this there is Export button,so after clicking this button excel file should be created for above displaying JTable. </p>
  
  <p>so cant recognized actual error</p>
  
  <pre><code>    JButton btnExport = new JButton("Export");
      btnExport.addActionListener(new ActionListener() 
      {
          public void actionPerformed(ActionEvent arg0)
          {
              try 
              {
                  String query="Select * from client";
                  PreparedStatement pst=conn.prepareStatement(query);
                  ResultSet rs=pst.executeQuery();
                  table.setModel(DbUtils.resultSetToTableModel(rs));
  
                  HSSFWorkbook wb = new HSSFWorkbook();
                  HSSFSheet sheet = wb.createSheet("Excel Sheet");
                  HSSFRow rowhead = sheet.createRow(0);
                  rowhead.createCell(0).setCellValue("Client_Vendor code");
                  rowhead.createCell(1).setCellValue("Client_Name");
                  rowhead.createCell(2).setCellValue("Purchaser_Name");
                  rowhead.createCell(3).setCellValue("User_Name");
                  rowhead.createCell(4).setCellValue("Sales_Engg");
  
                  int index=1;
                  while(rs.next())
                      {
                      HSSFRow row = sheet.createRow(index);
                      row.createCell(0).setCellValue(rs.getInt(1));
                      row.createCell(1).setCellValue(rs.getString(2));
                      row.createCell(2).setCellValue(rs.getString(3));
                      row.createCell(3).setCellValue(rs.getString(4));
                      row.createCell(4).setCellValue(rs.getString(5));
                      index++;
  
                      }  
  
                      FileOutputStream fileOut = new FileOutputStream("e:/CLIENTDATA/client.xlsx");
                      wb.write(fileOut);
                      fileOut.close();
                      System.out.println("Data is saved in excel file.");
                   }
                  catch (Exception e) 
              {
                  e.printStackTrace();
              }
  </code></pre>