title: How can I get excel data and convert it to JSON?
body: <p>I want to read the excel files(.xls,.xlsx) and convert it into JSON format and save it.</p>
  <p>Here is a code which enable me to read data from the excel file, but I am unable to get how to put data in JSON format.</p>
  <p>Can anyone help me out.</p>
  <pre><code>public class ReadExcelFile {
  private static XSSFWorkbook mybook;
  static String fileLocation = &quot;D://Traniee-SPG//Book1.xlsx&quot;;
  
  public static void main(String[] args){
      try{
          File newFile = new File(fileLocation);
          FileInputStream fIO = new FileInputStream(newFile);
          mybook = new XSSFWorkbook(fIO);         //finds the Excelfile
          XSSFSheet mySheet = mybook.getSheetAt(0);// Return first sheet from the XLSX workbook
          Iterator&lt;Row&gt; rowIterator = mySheet.iterator(); //create a cursor called iterator to all rows in sheet
          Row r;
          Cell c;
          //to travel into the Excel spreadsheet
          while(rowIterator.hasNext())    {
               r = rowIterator.next();
              //Cursor points to row
              Iterator&lt;Cell&gt; cell_Iterator = r.cellIterator();
              while(cell_Iterator.hasNext())  {
                   c = cell_Iterator.next();
                  //Cursor points to cell
                  switch (c.getCellType())    {
                  case Cell.CELL_TYPE_STRING:
                      System.out.print(c.getStringCellValue()+&quot;\t&quot;);
                      //System.out.println(&quot;Case String&quot;);
                      break;
                  case Cell.CELL_TYPE_NUMERIC:
                      System.out.print(c.getNumericCellValue()+&quot;\t&quot;);
                      //System.out.println(&quot;Case number&quot;);
                      break;
                  case Cell.CELL_TYPE_BOOLEAN:
                      System.out.print(c.getBooleanCellValue()+&quot;\t&quot;);
                      System.out.println(&quot;Case boolean&quot;);
                      break;
                  case Cell.CELL_TYPE_FORMULA:
                      System.out.print(c.getCellFormula()+&quot;\t&quot;);
                      //System.out.println(&quot;Case formula&quot;);
                      break;
                  default:
                  }                   
              }
              System.out.println(&quot; &quot;);//next to display in table format
         }            
          mybook.close();
          fIO.close();
      }
      catch(FileNotFoundException ef){
          ef.printStackTrace();
      }
      catch(IOException ei){
          ei.printStackTrace();
      }
  }
  </code></pre>
  <p>}</p>