Search code examples
javaandroidapache-poijxljxls

Excel generation in java


In Apache poi is there any provision for setting link between different sheets(For example i have an index page in my excel sheet which contains links to all my sheets. Can we do this for dynamic excel generation )? Is there any other libraries available for doing the same?


Solution

  • Yes that's possible, here is some example code:

    Cell cell = sheet.createRow(0).createCell(0);
    cell.setCellValue("Worksheet Link");
    HSSFHyperlink link = new HSSFHyperlink(HSSFHyperlink.LINK_DOCUMENT);
    link.setTextMark("'Target Sheet'!A1");
    cell.setHyperlink(link);
    

    Target Sheet is the name of the sheet to which the link should switch to and A1 is the target cell.