Harshavardhan Konakanchi
Harshavardhan Konakanchi

Reputation: 4294

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

Upvotes: 5

Views: 6583

Answers (1)

Mubin
Mubin

Reputation: 4239

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.

Upvotes: 4

Related Questions