Excel cell hyperlinks
GemBox.Spreadsheet for Java has been retired
GemBox.Spreadsheet for Java can read and write hyperlinks, but the level of support depends on the Excel file format:
- In XLSX and XLS, both
getHyperlink
andsetHyperlink
methods and HYPERLINK formula are supported. - In ODS and HTML, only
getHyperlink
andsetHyperlink
methods are supported.
You can set hyperlink to URL or to some location in the workbook.

import com.gembox.spreadsheet.*;
class Program {
public static void main(String[] args) throws java.io.IOException {
// If using the Professional version, put your serial key below.
SpreadsheetInfo.setLicense("FREE-LIMITED-KEY");
ExcelFile workbook = new ExcelFile();
ExcelWorksheet worksheet = workbook.addWorksheet("Hyperlinks");
worksheet.getCell("A1").setValue("Hyperlink examples:");
ExcelCell cell = worksheet.getCell("B3");
cell.setValue("GemBoxSoftware");
cell.getStyle().getFont().setUnderlineStyle(UnderlineStyle.SINGLE);
cell.getStyle().getFont().setColor(SpreadsheetColor.fromName(ColorName.BLUE));
cell.getHyperlink().setLocation("https://www.gemboxsoftware.com");
cell.getHyperlink().setExternal(true);
cell = worksheet.getCell("B5");
cell.setValue("Jump");
cell.getStyle().getFont().setUnderlineStyle(UnderlineStyle.SINGLE);
cell.getStyle().getFont().setColor(SpreadsheetColor.fromName(ColorName.BLUE));
cell.getHyperlink().setToolTip("This is tool tip! This hyperlink jumps to E1.");
cell.getHyperlink().setLocation(worksheet.getName() + "!E1");
worksheet.getCell("E1").setValue("Destination");
cell = worksheet.getCell("B8");
cell.setFormula("=HYPERLINK(\"https://www.gemboxsoftware.com/spreadsheet-java/examples/excel-cell-hyperlinks/207\", \"Example of HYPERLINK formula\")");
cell.getStyle().getFont().setUnderlineStyle(UnderlineStyle.SINGLE);
cell.getStyle().getFont().setColor(SpreadsheetColor.fromName(ColorName.BLUE));
workbook.save("Hyperlinks.%OutputFileType%");
}
}
See also
Next steps
Published: December 13, 2018 | Modified: December 19, 2022 | Author: Marek Turis