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 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

GemBox.Spreadsheet for Java is a component that enables you to read, write, edit and convert spreadsheet files from your applications using one simple API.

Download Buy