Excel cell hyperlinks

GemBox.Spreadsheet for Java can read and write hyperlinks, but the level of support depends on the Excel file format:

You can set hyperlink to URL or to some location in the workbook.

ExcelCell Hyperlinks Screenshot
import com.gembox.spreadsheet.*;

class Program {

    public static void main(String[] args) throws java.io.IOException {
        // If using 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%");
    }
}

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.


Like it?

Download Buy

If you want to try the GemBox.Spreadsheet for Java yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.