How can i make cell text in excel into Hyperlink .i.e suppose i have d:\screen\1.jpg in excel cell ,now make into hyprling,when user click on this then image should open .please sugget ,how can do it through selenium webdriver

How can i make cell text in excel into Hyperlink .i.e suppose i have d:\screen\1.jpg in excel cell ,now make into  hyprling,when  user click on this then image should open .please sugget ,how can do it through selenium webdriver

Add Comment
  • 1 Answer(s)

    You must be looking at this code

     Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
     CreationHelper createHelper = wb.getCreationHelper();
     //cell style for hyperlinks
     //by default hyperlinks are blue and underlined
     CellStyle hlink_style = wb.createCellStyle();
     Font hlink_font = wb.createFont();
     hlink_font.setUnderline(Font.U_SINGLE);
     hlink_font.setColor(IndexedColors.BLUE.getIndex());
     hlink_style.setFont(hlink_font);
     Cell cell;
     Sheet sheet = wb.createSheet("Hyperlinks");
     //URL
     cell = sheet.createRow(0).createCell((short)0);
     cell.setCellValue("URL Link");
     Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_URL);
     link.setAddress("http://poi.apache.org/");
     cell.setHyperlink(link);
     cell.setCellStyle(hlink_style);
     //link to a file in the current directory
     cell = sheet.createRow(1).createCell((short)0);
     cell.setCellValue("File Link");
     link = createHelper.createHyperlink(Hyperlink.LINK_FILE);
     link.setAddress("link1.xls");
     cell.setHyperlink(link);
     cell.setCellStyle(hlink_style);
    

    Virender

    Professor Answered on May 1, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.