Excel generation in java

396 views Asked by At

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?

2

There are 2 answers

0
Kai On BEST ANSWER

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.

1
Ninad Pingale On

You can use setAddress Method also.

HSSFHyperlink linkToSheet=new HSSFHyperlink(HSSFHyperlink.LINK_DOCUMENT);
linkToSheet.setAddress("ToSheet!A115");