// Create an instance of the class that exports Excel files, having two sheets
ExcelDocument workbook = new ExcelDocument(2);
// Set the sheet names
ExcelWorksheet xlsTab1 = (ExcelWorksheet) workbook.easy_getSheetAt(0);
ExcelWorksheet xlsTab2 = (ExcelWorksheet) workbook.easy_getSheetAt(1);
xlsTab1.setSheetName("First tab");
xlsTab2.setSheetName("Second tab");
// Create hyperlink to URL
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.URL,
"https://www.easyxls.com", "Link to URL", "B2:E2");
// Create hyperlink to file
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.FILE,
"c:\\myfile.xlsx", "Link to file", "B3");
// Create hyperlink to UNC
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.UNC,
"\\\\computerName\\Folder\\file.txt", "Link to UNC", "B4:D4");
// Create hyperlink to second sheet
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.CELL,
"'Second tab'!D3", "Link to CELL", "B5");
// Create a name on the second sheet
xlsTab2.easy_addName("Name", "=Second tab!$A$1:$A$4");
// Create hyperlink to name
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.CELL,
"Name", "Link to a name", "B6");
// Export Excel file
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel hyperlinks.xlsx");
' Create an instance of the class that exports Excel files, having two sheetsDim workbook As New ExcelDocument(2)
' Set the sheet namesDim xlsTab1 As ExcelWorksheet = workbook.easy_getSheetAt(0)
Dim xlsTab2 As ExcelWorksheet = workbook.easy_getSheetAt(1)
xlsTab1.setSheetName("First tab")
xlsTab2.setSheetName("Second tab")
' Create hyperlink to URL
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.URL, _
"https://www.easyxls.com", "Link to URL", "B2:E2")
' Create hyperlink to file
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.FILE, _
"c:\myfile.xlsx", "Link to file", "B3")
' Create hyperlink to UNC
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.UNC, _
"\\computerName\Folder\file.txt", "Link to UNC", "B4:D4")
' Create hyperlink to second sheet
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.CELL, _
"'Second tab'!D3", "Link to CELL", "B5")
' Create a name on the second sheet
xlsTab2.easy_addName("Name", "=Second tab!$A$1:$A$4")
' Create hyperlink to name
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.CELL, _
"Name", "Link to a name", "B6")
' Export Excel file
workbook.easy_WriteXLSXFile("C:\Samples\Excel hyperlinks.xlsx")
C++// Create an instance of the class that exports Excel files
EasyXLS::IExcelDocumentPtr workbook;
hr = CoCreateInstance(__uuidof(EasyXLS::ExcelDocument),
NULL,
CLSCTX_ALL,
__uuidof(EasyXLS::IExcelDocument),
(void**) &workbook) ;
if(SUCCEEDED(hr)){
// Create two sheets
workbook->easy_addWorksheet_2("First tab");
workbook->easy_addWorksheet_2("Second tab");
EasyXLS::IExcelWorksheetPtr xlsTab1 =
(EasyXLS::IExcelWorksheetPtr)workbook->easy_getSheetAt(0);
EasyXLS::IExcelWorksheetPtr xlsTab2 =
(EasyXLS::IExcelWorksheetPtr)workbook->easy_getSheetAt(1);
// Create hyperlink to URL
xlsTab1->easy_addHyperlink_3(HYPERLINKTYPE_URL,
"https://www.easyxls.com", "Link to URL", "B2:E2");
// Create hyperlink to file
xlsTab1->easy_addHyperlink_3(HYPERLINKTYPE_FILE,
"c:\\myfile.xlsx", "Link to file", "B3");
// Create hyperlink to UNC
xlsTab1->easy_addHyperlink_3(HYPERLINKTYPE_UNC,
"\\\\computerName\\Folder\\file.txt", "Link to UNC", "B4:D4");
// Create hyperlink to second sheet
xlsTab1->easy_addHyperlink_3(HYPERLINKTYPE_CELL,
"'Second tab'!D3", "Link to CELL", "B5");
// Create a name on the second sheet
xlsTab2->easy_addName_2("Name", "=Second tab!$A$1:$A$4");
// Create hyperlink to name
xlsTab1->easy_addHyperlink_3(HYPERLINKTYPE_CELL, "Name", "Link to a name", "B6");
// Export Excel file
workbook->easy_WriteXLSXFile("C:\\Samples\\Excel hyperlinks.xlsx");
Click here to see Continuous Code ListingC++.NET// Create an instance of the class that exports Excel files, having two sheets
ExcelDocument ^workbook = gcnew ExcelDocument(2);
// Set the sheet names
ExcelWorksheet ^xlsTab1 = safe_cast<ExcelWorksheet^>(workbook->easy_getSheetAt(0));
ExcelWorksheet ^xlsTab2 = safe_cast<ExcelWorksheet^>(workbook->easy_getSheetAt(1));
xlsTab1->setSheetName("First tab");
xlsTab2->setSheetName("Second tab");
// Create hyperlink to URL
xlsTab1->easy_addHyperlink(EasyXLS::Constants::HyperlinkType::URL,
"https://www.easyxls.com", "Link to URL", "B2:E2");
// Create hyperlink to file
xlsTab1->easy_addHyperlink(EasyXLS::Constants::HyperlinkType::FILE,
"c:\\myfile.xlsx", "Link to file", "B3");
// Create hyperlink to UNC
xlsTab1->easy_addHyperlink(EasyXLS::Constants::HyperlinkType::UNC,
"\\\\computerName\\Folder\\file.txt", "Link to UNC", "B4:D4");
// Create hyperlink to second sheet
xlsTab1->easy_addHyperlink(EasyXLS::Constants::HyperlinkType::CELL,
"'Second tab'!D3", "Link to CELL", "B5");
// Create a name on the second sheet
xlsTab2->easy_addName("Name", "=Second tab!$A$1:$A$4");
// Create hyperlink to name
xlsTab1->easy_addHyperlink(EasyXLS::Constants::HyperlinkType::CELL,
"Name", "Link to a name", "B6");
// Export Excel file
workbook->easy_WriteXLSXFile("C:\\Samples\\Excel hyperlinks.xlsx");
Click here to see Continuous Code Listing
// Create an instance of the class that exports Excel files, having two sheets
ExcelDocument workbook = new ExcelDocument(2);
// Set the sheet names
ExcelWorksheet xlsTab1 = (ExcelWorksheet) workbook.easy_getSheetAt(0);
ExcelWorksheet xlsTab2 = (ExcelWorksheet) workbook.easy_getSheetAt(1);
xlsTab1.setSheetName("First tab");
xlsTab2.setSheetName("Second tab");
// Create hyperlink to URL
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.URL,
"https://www.easyxls.com", "Link to URL", "B2:E2");
// Create hyperlink to file
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.FILE,
"c:\\myfile.xlsx", "Link to file", "B3");
// Create hyperlink to UNC
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.UNC,
"\\\\computerName\\Folder\\file.txt", "Link to UNC", "B4:D4");
// Create hyperlink to second sheet
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.CELL,
"'Second tab'!D3", "Link to CELL", "B5");
// Create a name on the second sheet
xlsTab2.easy_addName("Name", "=Second tab!$A$1:$A$4");
// Create hyperlink to name
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.CELL,
"Name", "Link to a name", "B6");
// Export Excel file
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel hyperlinks.xlsx");
.NET:// Create an instance of the class that exports Excel files
$workbook = new COM("EasyXLS.ExcelDocument");
// Create two sheets
$workbook->easy_addWorksheet_2("First tab");
$workbook->easy_addWorksheet_2("Second tab");
$xlsTab1 = $workbook->easy_getSheetAt(0);
$xlsTab2 = $workbook->easy_getSheetAt(1);
// Create hyperlink to URL
$xlsTab1->easy_addHyperlink_3($HYPERLINKTYPE_URL,
"https://www.easyxls.com", "Link to URL", "B2:E2");
// Create hyperlink to file
$xlsTab1->easy_addHyperlink_3($HYPERLINKTYPE_FILE,
"c:\\myfile.xlsx", "Link to file", "B3");
// Create hyperlink to UNC
$xlsTab1->easy_addHyperlink_3($HYPERLINKTYPE_UNC,
"\\\\computerName\\Folder\\file.txt", "Link to UNC", "B4:D4");
// Create hyperlink to second sheet
$xlsTab1->easy_addHyperlink_3($HYPERLINKTYPE_CELL,
"'Second tab'!D3", "Link to CELL", "B5");
// Create a name on the second sheet
$xlsTab2->easy_addName_2("Name", "=Second tab!\$A\$1:\$A\$4");
// Create hyperlink to name
$xlsTab1->easy_addHyperlink_3($HYPERLINKTYPE_CELL, "Name", "Link to a name", "B6");
// Export Excel file
$workbook->easy_WriteXLSXFile("C:\Samples\Excel hyperlinks.xlsx");
Click here to see Continuous Code ListingJava:// Create an instance of the class that exports Excel files
$workbook = new java("EasyXLS.ExcelDocument");
// Create two sheets
$workbook->easy_addWorksheet("First tab");
$workbook->easy_addWorksheet("Second tab");
$xlsTab1 = $workbook->easy_getSheetAt(0);
$xlsTab2 = $workbook->easy_getSheetAt(1);
// Create hyperlink to URL
$xlsTab1->easy_addHyperlink($HYPERLINKTYPE_URL, "https://www.easyxls.com", "Link to URL", "B2:E2");
// Create hyperlink to file
$xlsTab1->easy_addHyperlink($HYPERLINKTYPE_FILE, "c:\\myfile.xls", "Link to file", "B3");
// Create hyperlink to UNC
$xlsTab1->easy_addHyperlink($HYPERLINKTYPE_UNC, "\\\\computerName\\Folder\\file.txt",
"Link to UNC", "B4:D4");
// Create hyperlink to cell on second sheet
$xlsTab1->easy_addHyperlink($HYPERLINKTYPE_CELL, "'Second tab'!D3", "Link to CELL", "B5");
// Create a name on the second sheet
$xlsTab2->easy_addName("Name", "=Second tab!\$A\$1:\$A\$4");
// Create hyperlink to name
$xlsTab1->easy_addHyperlink($HYPERLINKTYPE_CELL, "Name", "Link to a name", "B6");
// Export Excel file
$workbook->easy_WriteXLSXFile("C:\Samples\Excel hyperlinks.xlsx");
Click here to see Continuous Code Listing
' Create an instance of the class that exports Excel filesset workbook = Server.CreateObject("EasyXLS.ExcelDocument")
' Create two sheets
workbook.easy_addWorksheet_2("First tab")
workbook.easy_addWorksheet_2("Second tab")
set xlsTab1 = workbook.easy_getSheetAt(0)
set xlsTab2 = workbook.easy_getSheetAt(1)
' Create hyperlink to URL
xlsTab1.easy_addHyperlink_3 HYPERLINKTYPE_URL, _
"https://www.easyxls.com", "Link to URL", "B2:E2"' Create hyperlink to file
xlsTab1.easy_addHyperlink_3 HYPERLINKTYPE_FILE, _
"c:\myfile.xlsx", "Link to file", "B3"' Create hyperlink to UNC
xlsTab1.easy_addHyperlink_3 HYPERLINKTYPE_UNC, _
"\\computerName\Folder\file.txt", "Link to UNC", "B4:D4"' Create hyperlink to second sheet
xlsTab1.easy_addHyperlink_3 HYPERLINKTYPE_CELL, _
"'Second tab'!D3", "Link to CELL", "B5"' Create a name on the second sheet
xlsTab2.easy_addName_2 "Name", "=Second tab!$A$1:$A$4"' Create hyperlink to name
xlsTab1.easy_addHyperlink_3 HYPERLINKTYPE_CELL, "Name", "Link to a name", "B6"' Export Excel file
workbook.easy_WriteXLSXFile("C:\Samples\Excel hyperlinks.xlsx")
' Create an instance of the class that exports Excel filesSet workbook = CreateObject("EasyXLS.ExcelDocument")
' Create two sheets
workbook.easy_addWorksheet_2("First tab")
workbook.easy_addWorksheet_2("Second tab")
Set xlsTab1 = workbook.easy_getSheetAt(0)
Set xlsTab2 = workbook.easy_getSheetAt(1)
' Create hyperlink to URL
xlsTab1.easy_addHyperlink_3 HyperlinkType.HYPERLINKTYPE_URL, _
"https://www.easyxls.com", "Link to URL", "B2:E2"' Create hyperlink to file
xlsTab1.easy_addHyperlink_3 HyperlinkType.HYPERLINKTYPE_FILE, _
"c:\myfile.xlsx", "Link to file", "B3"' Create hyperlink to UNC
xlsTab1.easy_addHyperlink_3 HyperlinkType.HYPERLINKTYPE_UNC, _
"\\computerName\Folder\file.txt", "Link to UNC", "B4:D4"' Create hyperlink to second sheet
xlsTab1.easy_addHyperlink_3 HyperlinkType.HYPERLINKTYPE_CELL, _
"'Second tab'!D3", "Link to CELL", "B5"' Create a name on the second sheet
xlsTab2.easy_addName_2 "Name", "=Second tab!$A$1:$A$4"' Create hyperlink to name
xlsTab1.easy_addHyperlink_3 HyperlinkType.HYPERLINKTYPE_CELL, _
"Name", "Link to a name", "B6"' Export Excel file
workbook.easy_WriteXLSXFile("C:\Samples\Excel hyperlinks.xlsx")
' Create an instance of the class that exports Excel filesset workbook = CreateObject("EasyXLS.ExcelDocument")
' Create two sheets
workbook.easy_addWorksheet_2("First tab")
workbook.easy_addWorksheet_2("Second tab")
set xlsTab1 = workbook.easy_getSheetAt(0)
set xlsTab2 = workbook.easy_getSheetAt(1)
' Create hyperlink to URL
xlsTab1.easy_addHyperlink_3 HYPERLINKTYPE_URL, _
"https://www.easyxls.com", "Link to URL", "B2:E2"' Create hyperlink to file
xlsTab1.easy_addHyperlink_3 HYPERLINKTYPE_FILE, _
"c:\myfile.xlsx", "Link to file", "B3"' Create hyperlink to UNC
xlsTab1.easy_addHyperlink_3 HYPERLINKTYPE_UNC, _
"\\computerName\Folder\file.txt", "Link to UNC", "B4:D4"' Create hyperlink to second sheet
xlsTab1.easy_addHyperlink_3 HYPERLINKTYPE_CELL, _
"'Second tab'!D3", "Link to CELL", "B5"' Create a name on the second sheet
xlsTab2.easy_addName_2 "Name", "=Second tab!$A$1:$A$4"' Create hyperlink to name
xlsTab1.easy_addHyperlink_3 HYPERLINKTYPE_CELL, "Name", "Link to a name", "B6"' Export Excel file
workbook.easy_WriteXLSXFile("C:\Samples\Excel hyperlinks.xlsx")
<!-- Create an instance of the class that exports Excel files --><cfobject type="java"class="EasyXLS.ExcelDocument"name="workbook"action="CREATE"><!-- Create two sheets --><cfset ret = workbook.easy_addWorksheet("First tab")><cfset ret = workbook.easy_addWorksheet("Second tab")><cfset xlsTab1 = workbook.easy_getSheetAt(0)><cfset xlsTab2 = workbook.easy_getSheetAt(1)><!-- Create hyperlink to URL --><cfset xlsTab1.easy_addHyperlink(HyperlinkType.URL,
"https://www.easyxls.com", "Link to URL", "B2:E2")><!-- Create hyperlink to file --><cfset xlsTab1.easy_addHyperlink(HyperlinkType.FILE,
"c:\myfile.xlsx", "Link to file", "B3")><!-- Create hyperlink to UNC --><cfset xlsTab1.easy_addHyperlink(HyperlinkType.UNC,
"\\computerName\Folder\file.txt", "Link to UNC", "B4:D4")><!-- Create hyperlink to second sheet --><cfset xlsTab1.easy_addHyperlink(HyperlinkType.CELL,
"'Second tab'!D3", "Link to CELL", "B5")><!-- Create a name on the second sheet --><cfset xlsTab2.easy_addName("Name", "=Second tab!$A$1:$A$4")><!-- Create hyperlink to name --><cfset xlsTab1.easy_addHyperlink(HyperlinkType.CELL, "Name", "Link to a name", "B6")><!-- Export Excel file --><cfset ret = workbook.easy_WriteXLSXFile("C:\Samples\Excel hyperlinks.xlsx")>
.NET:# Create an instance of the class that exports Excel files having two sheets
workbook = ExcelDocument(2)
# Set the sheet names
xlsTab1 = workbook.easy_getSheetAt(0)
xlsTab2 = workbook.easy_getSheetAt(1)
xlsTab1.setSheetName("First tab")
xlsTab2.setSheetName("Second tab")
# Create hyperlink to URL
xlsTab1.easy_addHyperlink(HyperlinkType.URL, "https://www.easyxls.com", "Link to URL", "B2:E2")
# Create hyperlink to file
xlsTab1.easy_addHyperlink(HyperlinkType.FILE, "c:\\myfile.xls", "Link to file", "B3")
# Create hyperlink to UNC
xlsTab1.easy_addHyperlink(HyperlinkType.UNC, "\\\\computerName\\Folder\\file.txt", "Link to UNC", "B4:D4")
# Create hyperlink to cell on second sheet
xlsTab1.easy_addHyperlink(HyperlinkType.CELL, "'Second tab'!D3", "Link to CELL", "B5")
# Create a name on the second sheet
xlsTab2.easy_addName("Name", "=Second tab!$A$1:$A$4")
# Create hyperlink to name
xlsTab1.easy_addHyperlink(HyperlinkType.CELL, "Name", "Link to a name", "B6")
# Export Excel file
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel hyperlinks.xlsx")
Click here to see Continuous Code ListingJava:# Create an instance of the class that exports Excel files having two sheets
workbook = gateway.jvm.ExcelDocument(2)
# Set the sheet names
xlsTab1 = workbook.easy_getSheetAt(0)
xlsTab2 = workbook.easy_getSheetAt(1)
xlsTab1.setSheetName("First tab")
xlsTab2.setSheetName("Second tab")
# Create hyperlink to URL
xlsTab1.easy_addHyperlink(gateway.jvm.HyperlinkType.URL, "https://www.easyxls.com",
"Link to URL", "B2:E2")
# Create hyperlink to file
xlsTab1.easy_addHyperlink(gateway.jvm.HyperlinkType.FILE, "c:\\myfile.xls", "Link to file", "B3")
# Create hyperlink to UNC
xlsTab1.easy_addHyperlink(gateway.jvm.HyperlinkType.UNC, "\\\\computerName\\Folder\\file.txt",
"Link to UNC", "B4:D4")
# Create hyperlink to cell on second sheet
xlsTab1.easy_addHyperlink(gateway.jvm.HyperlinkType.CELL, "'Second tab'!D3", "Link to CELL", "B5")
# Create a name on the second sheet
xlsTab2.easy_addName("Name", "=Second tab!$A$1:$A$4")
# Create hyperlink to name
xlsTab1.easy_addHyperlink(gateway.jvm.HyperlinkType.CELL, "Name", "Link to a name", "B6")
# Export Excel file
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel hyperlinks.xlsx")
Click here to see Continuous Code Listing
The screen shot provides an example of an Excel file with hyperlinks to URL, file, UNC, another sheet and name.
Export hyperlink to Excel file
EasyXLS allows you to export Excel files with hyperlinks using ExcelWorksheet.easy_addHyperlink method. The above code sample shows how to achieve this goal.
EasyXLS allows you to read hyperlinks from Excel file using ExcelWorksheet.easy_getHyperlinkAt method. The Excel file must be imported first and after that the hyperlinks are available on each sheet.