title: how to add images in HSSFCell in apache POI?
body: <p>How to add Image in different different HSSFCell object in poi ?</p>
  
  <p>I have written some code which is adding image but problem is, the cell were I added last image, That cell only showing image other than that no other cells are showing images ...</p>
  
  <p>appreciate your help ...</p>
  
  <p>My Code is </p>
  
  <pre><code>while(rs.next()){
  
      HSSFCell cell = getHSSFCell(sheet, rowNo, cellNo);
  
      cell.setCellValue(new HSSFRichTextString(rs.getString("TEST_STEP_DETAILS")) );
      cell.setCellStyle(style);
  
      String annotate = rs.getString("ANNOTATE");
  
      if(annotate != null){                       
          int index = getPicIndex(wb);
          HSSFPatriarch patriarch=sheet.createDrawingPatriarch();
          HSSFClientAnchor anchor = new HSSFClientAnchor(400,10,655,200,(short)cellNo,(rowNo+1),(short)cellNo,(rowNo+1));
          anchor.setAnchorType(1);
          patriarch.createPicture(anchor, index);                                         
      }
      cellNo++;
  }
  </code></pre>
  
  <p>getPicIndex METHOD :- </p>
  
  <pre><code>public static int getPicIndex(HSSFWorkbook wb){
      int index = -1;
      try {
          byte[] picData = null;
          File pic = new File( "C:\\pdf\\logo.jpg" );
          long length = pic.length(  );
          picData = new byte[ ( int ) length ];
          FileInputStream picIn = new FileInputStream( pic );
          picIn.read( picData );
          index = wb.addPicture( picData, HSSFWorkbook.PICTURE_TYPE_JPEG );
      } catch (IOException e) {
          e.printStackTrace();
      }  catch (Exception e) {
          e.printStackTrace();
      } 
      return index;
  }
  </code></pre>