title: How to read Excel (.xlsx) file in java?
body: <p>From a given <code>.xlsx</code> file, I am trying to read data using Java.</p>
  
  <p><a href="https://i.stack.imgur.com/FBHG0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FBHG0.png" alt="enter image description here"></a></p>
  
  <p>My code for reading the file is as follows:</p>
  
  <pre><code>public static void main(String[] args) throws Exception {
  
          FileInputStream file = new FileInputStream(new File("E:\\test1.xlsx"));
          XSSFWorkbook workbook = new XSSFWorkbook(file);
          XSSFSheet test = workbook.getSheetAt(0);
  
          student emp = new student();
          Iterator&lt;Row&gt; itr = test.iterator();
          itr.next();
          while(itr.hasNext()){
                 Row row = itr.next();
                 emp.reedData(row);
                 System.out.println(id+","+name+","+options);
          }
  </code></pre>
  
  <p>The method is as follows:</p>
  
  <pre><code>void reedData(Row row){
      id= row.getCell(0).toString();
      name= row.getCell(1).toString();
      options= row.getCell(2).toString();
  }
  </code></pre>
  
  <p>But, I am getting output like this:</p>
  
  <pre><code>1.0,X,play game
  ,,sing song
  2.0,Y,play game
  ,,sing song
  </code></pre>
  
  <p>Instead of the above, I want the output to look like this:</p>
  
  <pre><code>1.0,X,{play game,sing song}
  2.0,Y,{play game,sing song}
  </code></pre>
  
  <p>This problem is because I am merging two cells in <code>.xlsx</code> file.</p>
  
  <p>Any suggestion?
  thank you in advance..</p>