Oleksandr H
Oleksandr H

Reputation: 3015

Apache POI does not shows hyperlinks in file

I have the following problem. I get code from example:

Hyperlink  link = createHelper.createHyperlink(Hyperlink.LINK_URL);
link.setAddress("https://google.com");
link.setLabel("xxxx");
row.createCell(0).setHyperlink(link);

But, when I open my xlsx file, I see empty cell. Other values are present. I'm using Apache POI 3.11, Libre Office on Windows 7. What is wrong?

Upvotes: 1

Views: 370

Answers (2)

Roman Danilov
Roman Danilov

Reputation: 371

You don't have to use link.setLabel("xxxx"); method, you should use cell.setValue("xxxx") instead:

Hyperlink  link = createHelper.createHyperlink(Hyperlink.LINK_URL);
link.setAddress("https://google.com");
Cell cell = row.createCell(0);
cell.setHyperlink(link);
cell.setCellValue("xxxx");

Upvotes: 1

Seckin Celik
Seckin Celik

Reputation: 182

Cast createHelper as such: (Hyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);

Upvotes: 0

Related Questions