Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a hyperlink using apache poi

I am trying to create a hyperlink using the following code

CreationHelper createHelper = wb.getCreationHelper();
cell.setCellValue("Click Here");
Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_FILE);

File f = new File("C:\\Test\\1.pdf");
link.setAddress(f.getCanonicalPath());
cell.setHyperlink((org.apache.poi.ss.usermodel.Hyperlink) link);

It works fine and it adds a link Click Here to the cell

But how i can set a partial text and a link using same type of code,
I mean the link need to be like your file is here, where only here is the link

like image 692
Harshavardhan Konakanchi Avatar asked Oct 03 '22 19:10

Harshavardhan Konakanchi


1 Answers

As far as I know I don't think it is possible, as it is not supported by Excel as well. To achieve that in Excel too there is no straight way and you have to do some tricks to achieve that. Something that is not supported right from Excel cannot be supported by Apache POI too.

like image 200
Mubin Avatar answered Oct 07 '22 15:10

Mubin