Reputation: 1076
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?
Upvotes: 1
Views: 390
Reputation: 7069
You can use setAddress Method also.
HSSFHyperlink linkToSheet=new HSSFHyperlink(HSSFHyperlink.LINK_DOCUMENT);
linkToSheet.setAddress("ToSheet!A115");
Upvotes: 1
Reputation: 39641
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.
Upvotes: 3