title: How to add a hyperlink in XLS cell using JAVA
body: <p>I need to add a hyperlink in XLS cell which should be linked to the file in my local drive using Java. Here is my code.</p>
  
  <p>I need to link the corresponding file from the local folder to the corresponding cell in the XLs.</p>
  
  <p>I'd tried to add hyperlink, but i can able add only URL in the not the file from the local disk. Please help me</p>
  
  <pre><code>public boolean to_write_xls( int max, List &lt;String&gt; temp_1,List &lt;String&gt; temp_2,List &lt;String&gt; temp_3,List &lt;String&gt; temp_4,List &lt;String&gt; temp_5 ) {
  
  HSSFWorkbook workbook = new HSSFWorkbook();
  HSSFSheet sheet = workbook.createSheet("Analyzed Result");
  HSSFRow rowhead = sheet.createRow((short) 0);
  CellStyle style = workbook.createCellStyle();
  style.setFillForegroundColor(HSSFColor.ORANGE.index);
  style.setFillPattern(CellStyle.SOLID_FOREGROUND);
  style.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
  style.setBorderTop(HSSFCellStyle.BORDER_THICK);
  style.setBorderRight(HSSFCellStyle.BORDER_THIN);
  style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  
      rowhead.createCell((short) 0).setCellValue("Passed TC's     ");
      rowhead.createCell((short) 1).setCellValue("CRC:Failure     ");
      rowhead.createCell((short) 2).setCellValue("unexpected RRC PDU");
      rowhead.createCell((short) 3).setCellValue("PCallback Error ");
      rowhead.createCell((short) 4).setCellValue("Piggybacked NAS PDU");
  
  /*    for (int i=0; i&lt;5; i++){
         // sheet.setColumnWidth(i,4000);
          sheet.autoSizeColumn((short)i);
  
  
      }*/
      Iterator&lt;Cell&gt; ct = rowhead.iterator();
      int i=0;
      while(ct.hasNext()){
          Cell cell = (Cell) ct.next();
          cell.setCellStyle(style);
          sheet.autoSizeColumn((short)i);
          i ++;
      }
      CellStyle style_r = workbook.createCellStyle();
      style_r.setBorderBottom(HSSFCellStyle.BORDER_THIN);
      style_r.setBorderTop(HSSFCellStyle.BORDER_THIN);
      style_r.setBorderRight(HSSFCellStyle.BORDER_THIN);
      style_r.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  
      i=0;
      while (i &lt; max ) {
  
          HSSFRow row = sheet.createRow((short) i+2);
  
          row.createCell((short) 0).setCellValue(temp_1.get(i));
          row.createCell((short) 1).setCellValue(temp_2.get(i));
          row.createCell((short) 2).setCellValue(temp_3.get(i));
          row.createCell((short) 3).setCellValue(temp_4.get(i));
          row.createCell((short) 4).setCellValue(temp_5.get(i));
  
          Iterator&lt;Cell&gt; rw = row.iterator();
           while(rw.hasNext()){
              Cell cell = (Cell) rw.next();
              cell.setCellStyle(style_r);
           }
          i++;
          }      
  
  
  
  
      try {
  
           FileOutputStream Fout =
       new FileOutputStream(new File(fin+"\\Result.xls"));
       workbook.write(Fout);
       Fout.close();
       //System.out.println("Excel written successfully..with the file name directory-----&gt; D:\\_Analyzed_Result\\Result.xls");
           Runtime.getRuntime().exec("cmd /c start "+fin+"\\Result.xls"); 
       } catch (Exception e) {
       e.printStackTrace();
  
       return false;
   }
  
  
  return true;
  </code></pre>
  
  <p>}</p>