- Document Solutions for Excel, Java Edition Overview
- Key Features
- Getting Started
-
Features
- Worksheet
- Workbook
- Comments
- Hyperlinks
- Sort
- Filter
- Group
- Conditional Formatting
- Data Validations
- Data Binding
- Import Data
- Digital Signatures
- Formulas
- Custom Functions
- Shapes
- Document Properties
- Styles
- Form Controls
- Barcodes
- Themes and Colors
- Chart
- Table
- Pivot Table
- Pivot Chart
- Sparkline
- Slicer
- Print Settings
- Logging
- Defined Names
- Templates
- File Operations
- Use JDK 8 Date Time API
- Document Solutions Data Viewer
- API Reference
- Release Notes
Hyperlinks
With DsExcel Java, you can insert and manage hyperlinks in the cells of the worksheets without any hassle.
Basically, a hyperlink in a cell refers to the hypertext link that is entered into a cell in order to assign data reference that point to another externally located file or a section within the document. Users can insert multiple hyperlinks in a worksheet or a cell range depending on the requirements.
In DsExcel Java, you can work with hyperlinks in the following ways:
Add hyperlinks
Hyperlinks can be added via linking to an external file, linking to a webpage, linking to an email address and linking to a cell or a range of cells within the worksheet. You can insert hyperlinks using the add method of the IHyperlinks interface.
In order to add hyperlinks to an external file, to a webpage, to a range within the worksheet and to an email address; refer to the following example code.
// Add hyperlink to an external file
worksheet.getRange("A1:B2").getHyperlinks().add(worksheet.getRange("A1"),
"C:\Documents\Project\Hyperlink\SampleFile.xlsx",
null,
"link to SampleFile.xlsx file.",
"SampleFile.xlsx");// Add hyperlink to a webpage
worksheet.getRange("A1:B2").getHyperlinks().add(worksheet.getRange("A1"),
"https://developer.mescius.com/", null, "open Mescius website.","MESCIUS, Inc.");// Add hyperlink to a range in this document
worksheet.getRange("A1:B2").getHyperlinks().add(worksheet.getRange("A1"),
null, "Sheet1!$C3ドル:$E4ドル", "Go To sheet1 C3:E4","");// Add hyperlink to a range in this document
worksheet.getRange("A1:B2").getHyperlinks().add(worksheet.getRange("A1"),
"mailto:us.sales@mescius.com",
null,
"Send an email to sales department",
"Send To US Sales");Configure Hyperlinks
You can configure hyperlinks using the methods of the IHyperlink interface.
The methods of the IHyperlink interface enables users to configure the hyperlink references. The table shared below illustrates some examples:
Link To
Address
SubAddress
External File
Example: "C:\Documents\Project\Hyperlink\SampleFile.xlsx"
null
Webpage
Example: "https://developer.mescius.com/"
null
A range in this document
Example: null
"Sheet1!$C3ドル:$E4ドル"
Email Address
Example: mailto:us.sales@mescius.com
null
You can set the text of hyperlink's email subject line.
You can set the tip text for the specified hyperlink.
You can set the text to be displayed for the specified hyperlink.
Delete Hyperlinks
The hyperlinks added in the cells can be deleted from the worksheet or in a specific cell range using the delete method.
In order to remove hyperlinks, refer to the following example code.
// Delete hyperlinks
worksheet.getRange("A1:B2").getHyperlinks().add(worksheet.getRange("A1:A2"), null, "Sheet1!$C3ドル:$E4ドル", "Go To sheet1 C3:E4", "");
worksheet.getRange("H5").getHyperlinks().add(worksheet.getRange("A1"), "https://developer.mescius.com");
worksheet.getRange("J6").getHyperlinks().add(worksheet.getRange("A1"), "https://developer.mescius.com");
// Delete hyperlinks in range A1:A2
worksheet.getRange("A1:A2").getHyperlinks().delete();
// Delete all hyperlinks in this worksheet
worksheet.getHyperlinks().delete();