title: need help to for wring excel with hyperlink field file in java
body: <p>i am trying to write excel file through the java which has hyperlink field. </p>
  
  <p>i am writing it from object list. please check my code.</p>
  
  <p>it is working when i am giving object list. and it is writing xls file. </p>
  
  <p>but i also want to write hyperlink in it. what should i change in following code.?</p>
  
  <p><strong>Just Start From exportToExcel method.</strong></p>
  
  <pre><code>package com.ksh;
  
  import java.io.ByteArrayOutputStream;
  import java.io.File;
  import java.io.FileOutputStream;
  import java.lang.reflect.Field;
  import java.lang.reflect.Modifier;
  import java.math.BigDecimal;
  import java.text.DecimalFormat;
  import java.text.SimpleDateFormat;
  import java.util.ArrayList;
  import java.util.Date;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  
  import org.apache.poi.xssf.usermodel.XSSFCell;
  import org.apache.poi.xssf.usermodel.XSSFRow;
  import org.apache.poi.xssf.usermodel.XSSFSheet;
  import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  
  import com.ksh.Final.Link;
  
  public class OwnClass {
  
      private static SimpleDateFormat dateTimeFormatter = new SimpleDateFormat("yyyyMMddHHmmss");
      @SuppressWarnings({ "unchecked", "rawtypes" })
      private static Map&lt;Class&lt;?&gt;, Class&lt;?&gt;&gt; javaBasicObjectTypeMap = new HashMap();
      @SuppressWarnings({ "unchecked", "rawtypes" })
      private static Map&lt;Class&lt;?&gt;, Class&lt;?&gt;&gt; floatingPointTypeMap = new HashMap();
  
      static 
      {
          javaBasicObjectTypeMap.put(Integer.class, Integer.class);
          javaBasicObjectTypeMap.put(Long.class, Long.class);
          javaBasicObjectTypeMap.put(Float.class, Float.class);
          javaBasicObjectTypeMap.put(Double.class, Double.class);
          javaBasicObjectTypeMap.put(BigDecimal.class, BigDecimal.class);
          javaBasicObjectTypeMap.put(Character.class, Character.class);
          javaBasicObjectTypeMap.put(String.class, String.class);
          javaBasicObjectTypeMap.put(Date.class, Date.class);
  
          floatingPointTypeMap.put(Float.class, Float.class);
          floatingPointTypeMap.put(Double.class, Double.class);
          floatingPointTypeMap.put(BigDecimal.class, BigDecimal.class);
      }
  
      @SuppressWarnings("rawtypes")
      public static String exportToExcel(List&lt;?&gt; objectList, 
                                         ExcelFileParameter config, 
                                         Map&lt;String, String&gt; fieldNameTitleMap)throws Exception
      {
          String filePath = config.getExcelFileAbsolutePath();
          if (filePath.isEmpty()) 
          {
              filePath = dateTimeFormatter.format(new Date()) + ".xlsx";
          }
          File excelFile = new File(filePath);
          FileOutputStream fos = null;
          XSSFWorkbook workBook = new XSSFWorkbook();
          XSSFSheet sheet = workBook.createSheet();
          List rowlist = convertObjectToRowList(objectList, config, fieldNameTitleMap);
  
          System.out.println("Kshitij : "+rowlist.size()+"Type : ===="+rowlist.get(0).getClass().getName());
  
          for (int i = 0; (rowlist != null) &amp;&amp; (i &lt; rowlist.size()); i++) 
          {
              List row = (List)rowlist.get(i);
              XSSFRow excelRow = sheet.createRow(i);
              for (int j = 0; (row != null) &amp;&amp; (j &lt; row.size()); j++) 
              {
                  XSSFCell cell = excelRow.createCell(j);
                  cell.setCellValue((String)row.get(j));
              }
          }
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          workBook.write(bos);
          try
          {
              fos = new FileOutputStream(excelFile);
              fos.write(bos.toByteArray());
          } 
          catch (Exception ex) 
          {
              throw ex;
          } 
          finally 
          {
              fos.flush();
              fos.close();
          }
  
          return excelFile.getAbsolutePath();
      }
  
      @SuppressWarnings({ "rawtypes", "unchecked" })
      private static List&lt;List&lt;String&gt;&gt; convertObjectToRowList(List&lt;?&gt; objectList, 
                                                               ExcelFileParameter config, 
                                                               Map&lt;String, String&gt; fieldNameTitleMap) throws Exception
  
      {
          if (objectList == null) 
          {
              throw new Exception("objectList is null!");
          }
          if (objectList.size() == 0) 
          {
              throw new Exception("objectList is empty!");
          }
  
          List rowList = new ArrayList();
          Class itemClass = objectList.get(0).getClass();
          System.out.println("Object List Type is : "+itemClass.getName());
  
          if (javaBasicObjectTypeMap.containsKey(itemClass))
          {
                System.out.println("Non Primitive Type From Java Library");
                for (Iterator localIterator = objectList.iterator(); localIterator.hasNext(); ) 
                { 
                    Object obj = localIterator.next();
                    String value = convertFieldValueToString(itemClass, obj, config);
                    List row = new ArrayList();
                    row.add(value);
                    rowList.add(row);
                }
          }
          else
          {
                System.out.println("User Defined Class Type just got");
                List allFields = getFields(itemClass);
                Object excelFields = new ArrayList();
                List header = new ArrayList();
                String fieldName = null;
  
                for (int i = 0; (allFields != null) &amp;&amp; (i &lt; allFields.size()); i++) 
                {
                      fieldName = ((Field)allFields.get(i)).getName();
                      if ((fieldNameTitleMap != null) &amp;&amp; (fieldNameTitleMap.keySet().size() &gt; 0)) 
                      {
                          if (fieldNameTitleMap.containsKey(fieldName)) 
                          {
                              ((List)excelFields).add((Field)allFields.get(i));
                              header.add((String)fieldNameTitleMap.get(fieldName));
                          }
                      } 
                      else 
                      {
                          ((List)excelFields).add((Field)allFields.get(i));
                          header.add(fieldName);
                      }
                }
                rowList.add(header);
                for(Object object : objectList)
                {
                    List row = convertToRow(object, config, (List)excelFields);
                    rowList.add(row);
                }
          }
          return rowList;
        }
  
        private static String convertFieldValueToString(Class&lt;?&gt; fieldType, 
                                                        Object fieldValue, 
                                                        ExcelFileParameter config) throws Exception 
        {
  
              if (fieldValue == null) 
              {
                  return config.getNullValueStrig();
              }
              if (fieldType.isAssignableFrom(Date.class)) 
              {
                  SimpleDateFormat dateTimeFormat = config.getDateTimeFormat();
                  if (dateTimeFormat == null) 
                  {
                      return fieldValue.toString();
                  }
                  dateTimeFormat.format(fieldValue);
              }
  
              if ((fieldType == Float.TYPE)  || 
                  (fieldType == Double.TYPE) || 
                  (floatingPointTypeMap.containsKey(fieldType)))
              {
                    DecimalFormat decimalFormat = config.getDecimalFormat();
                    if (decimalFormat == null) 
                    {
                      return fieldValue.toString();
                    }
                    decimalFormat.format(fieldValue);
              }
  
              System.out.println("99999999999999999999999999999999999999999 : "+fieldType);
              if(fieldType == Link.class)
              {
                  System.out.println("Link Value is Found...");
                  System.out.println("Field Value : "+fieldValue.toString());
              }
  
              return fieldValue.toString();
        }
  
        @SuppressWarnings({ "rawtypes", "unchecked" })
        private static List&lt;Field&gt; getFields(Class&lt;?&gt; clazz)
        {
              List list = new ArrayList();
              Field[] fieldlist = clazz.getDeclaredFields();
              for (int i = 0; (fieldlist != null) &amp;&amp; (i &lt; fieldlist.length); i++)
              {
                  Field field = fieldlist[i];
                  Class type = fieldlist[i].getType();
                  System.out.println("Type :" +type);
                  int mod = fieldlist[i].getModifiers();
                  System.out.println("Mode :" +mod);
                  if ((!Modifier.isFinal(mod)) &amp;&amp; (!Modifier.isStatic(mod))) 
                  {
                      if (type.isPrimitive())
                      {
                          list.add(field);
                      }
                      else if (javaBasicObjectTypeMap.containsKey(type)) 
                      {
                          list.add(field);
                      }
                  }
              }
              for(Object object : list)
              {
                  Field field = (Field) object;
                  System.out.println(field.getName());
              }
              return list;
  
        }
  
        @SuppressWarnings({ "rawtypes", "unchecked" })
        private static List&lt;String&gt; convertToRow( Object object, 
                                                  ExcelFileParameter config, 
                                                  List&lt;Field&gt; fieldList )
        {
  
            List row = new ArrayList();
            for (int i = 0; (fieldList != null) &amp;&amp; (i &lt; fieldList.size()); i++) 
            {
                try 
                {
                    Field field = (Field)fieldList.get(i);
                    field.setAccessible(true);
                    Class fieldType = field.getType();
                    Object fieldValue = field.get(object);
  //                System.out.println("Field Type : "+fieldType +"FieldValue : "+fieldValue);
                    String value = convertFieldValueToString(fieldType, fieldValue, config);
                    System.out.println("--------------------------------------------------"+value);
                    row.add(value);
  
                } 
                catch (Exception ex) 
                {
                    row.add("ERROR:" + ex.toString());
                }
            }
            System.out.println("kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"+row.size());
          return row;
        }
  
  
  }
  </code></pre>
  
  <p>Means that will take object link write it to the excel file. its is working but need to write hyperlink field.</p>