Search results

Hyperlink in Vue Spreadsheet component

20 Apr 2021 / 4 minutes to read

Hyperlink is used to navigate to web links or cell reference within the sheet or to other sheets in Spreadsheet. You can use the allowHyperlink property to enable or disable hyperlink functionality.

  • The default value for allowHyperlink property is true.

You can insert a hyperlink in a worksheet cell for quick access to related information.

User Interface:

In the active spreadsheet, click the cell where you want to create a hyperlink. Insert hyperlink can be done by any of the following ways:

  • Select the INSERT tab in the Ribbon toolbar and choose the Link item.
  • Right-click the cell and then click Hyperlink item in the context menu.
  • Use Ctrl + K keyboard shortcut to apply the hyperlink.
  • Use the addHyperlink method programmatically.

You can change an existing hyperlink in your workbook by changing its destination or the text that is used to represent it.

User Interface:

In the active spreadsheet, Select the cell that contains the hyperlink that you want to change. Editing the hyperlink while opening the dialog can be done by any one of the following ways:

  • Select the INSERT tab in the Ribbon toolbar and choose the Link item.
  • Right-click the cell and then click Edit Hyperlink item in the context menu, or you can press Ctrl+K.

In the Edit Link dialog box, make the changes that you want, and click UPDATE.

Performing this operation remove a single hyperlink without losing the display text.

User Interface:

In the active spreadsheet, click the cell where you want to remove a hyperlink. remove hyperlink can be done by any of the following ways:

  • Right-click the cell and then click Remove Hyperlink item in the context menu.
  • Use the removeHyperlink() method programmatically.

How to change target attribute

There is an event named beforeHyperlinkClick which triggers only on clicking hyperlink. You can customize where to open the hyperlink by using the target property in the arguments of that event.

Source
Preview
app.vue
data.js
Copied to clipboard
<template>
   <ejs-spreadsheet ref="spreadsheet" :beforeHyperlinkClick="beforeHyperlinkClick">
   <e-sheets>
      <e-sheet name="PriceDetails">
         <e-rows>
                <e-row>
                        <e-cells>
                            <e-cell value="Item Name"></e-cell>
                            <e-cell value="Stock Detail"></e-cell>
                            <e-cell value="Website"></e-cell>
                        </e-cells>
                    </e-row>
                    <e-row>
                        <e-cells>
                            <e-cell value="Casual Shoes"></e-cell>
                            <e-cell value="OUT OF STOCK"></e-cell>
                            <e-cell value="Amazon" hyperlink="https://www.amazon.com/"></e-cell>
                        </e-cells>
                    </e-row>
                    <e-row>
                        <e-cells>
                            <e-cell value="Sports Shoes"></e-cell>
                            <e-cell value="IN STOCK" hyperlink="Stock!A2:B2"></e-cell>
                            <e-cell value="Overstack" hyperlink="https://www.overstock.com/"></e-cell>
                        </e-cells>
                    </e-row>
                    <e-row>
                        <e-cells>
                            <e-cell value="Formal Shoes"></e-cell>
                            <e-cell value="IN STOCK" hyperlink="Stock!A3:B3"></e-cell>
                            <e-cell value="AliExpress" hyperlink="https://www.aliexpress.com/"></e-cell>
                        </e-cells>
                    </e-row>
                    <e-row>
                        <e-cells>
                            <e-cell value="Sandals & Floaters"></e-cell>
                            <e-cell value="OUT OF STOCK"></e-cell>
                            <e-cell value="AliBaba" hyperlink="https://www.aliBaba.com/"></e-cell>
                        </e-cells>
                    </e-row>
                    <e-row>
                        <e-cells>
                            <e-cell value="Flip-Flops & Slippers"></e-cell>
                            <e-cell value="IN STOCK" hyperlink="Stock!A4:B4"></e-cell>
                            <e-cell value="Taobao" hyperlink="https://www.taobao.com/"></e-cell>
                        </e-cells>
                    </e-row>
                </e-rows>
        <e-columns>
          <e-column :width="width1"></e-column>
          <e-column :width="width1"></e-column>
          <e-column :width="width2"></e-column>
        </e-columns>
      </e-sheet>
      <e-sheet name="Stock">
         <e-rows>
                <e-row>
                        <e-cells>
                            <e-cell value="Item Name"></e-cell>
                            <e-cell value="Available Count"></e-cell>
                        </e-cells>
                    </e-row>
                    <e-row>
                        <e-cells>
                            <e-cell value="Sports Shoes"></e-cell>
                            <e-cell value="30"></e-cell>
                        </e-cells>
                    </e-row>
                    <e-row>
                        <e-cells>
                            <e-cell value="Formal Shoes"></e-cell>
                            <e-cell value="25"></e-cell>
                        </e-cells>
                    </e-row>
                    <e-row>
                        <e-cells>
                            <e-cell value="Flip-Flops & Slippers"></e-cell>
                            <e-cell value="40"></e-cell>
                        </e-cells>
                    </e-row>
                    <e-row>
                        <e-cells>
                            <e-cell value="Running Shoes"></e-cell>
                            <e-cell value="25"></e-cell>
                        </e-cells>
                    </e-row>
                </e-rows>
        <e-columns>
          <e-column :width="width1"></e-column>
          <e-column :width="width2"></e-column>
        </e-columns>
      </e-sheet>
    </e-sheets></ejs-spreadsheet>
</template>

<script>
import Vue from "vue";
import { SpreadsheetPlugin } from "@syncfusion/ej2-vue-spreadsheet";
Vue.use(SpreadsheetPlugin);
export default {
   data: () => {
return {
  width1: 160,
  width2: 120,
}
  },
  methods: {
  beforeHyperlinkClick: function (args) {
  args.target = '_self'; //change target attribute
  }
}
}
</script>
<style>
 @import "../node_modules/@syncfusion/ej2-vue-spreadsheet/styles/material.css";
 @import '../node_modules/@syncfusion/ej2-base/styles/material.css';  
 @import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';  
 @import '../node_modules/@syncfusion/ej2-dropdowns/styles/material.css';  
 @import '../node_modules/@syncfusion/ej2-inputs/styles/material.css';  
 @import '../node_modules/@syncfusion/ej2-navigations/styles/material.css';
 @import '../node_modules/@syncfusion/ej2-popups/styles/material.css';
 @import '../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css';
 @import '../node_modules/@syncfusion/ej2-grids/styles/material.css';
 @import "../node_modules/@syncfusion/ej2-spreadsheet/styles/material.css";
</style>
Copied to clipboard
define(["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.tradeData = [
        {
          "EmployeeID": 10001,
          "Employees": "Laura Nancy",
          "Designation": "Designer",
          "Location": "France",
          "Status": "Inactive",
          "Trustworthiness": "Sufficient",
          "Rating": 0,
          "Software": 69,
          "EmployeeImg": "usermale",
          "CurrentSalary": 84194,
          "Address": "Taucherstraße 10",
          "Mail": "laura15@jourrapide.com"
        },
        {
          "EmployeeID": 10002,
          "Employees": "Zachery Van",
          "Designation": "CFO",
          "Location": "Canada",
          "Status": "Inactive",
          "Trustworthiness": "Insufficient",
          "Rating": 3,
          "Software": 99,
          "EmployeeImg": "usermale",
          "CurrentSalary": 55349,
          "Address": "5ª Ave. Los Palos Grandes",
          "Mail": "zachery109@sample.com"
        },
        {
          "EmployeeID": 10003,
          "Employees": "Rose Fuller",
          "Designation": "CFO",
          "Location": "France",
          "Status": "Active",
          "Trustworthiness": "Insufficient",
          "Rating": 1,
          "Software": 1,
          "EmployeeImg": "usermale",
          "CurrentSalary": 16477,
          "Address": "2817 Milton Dr.",
          "Mail": "rose55@rpy.com"
        },
        {
          "EmployeeID": 10004,
          "Employees": "Jack Bergs",
          "Designation": "Manager",
          "Location": "Mexico",
          "Status": "Inactive",
          "Trustworthiness": "Insufficient",
          "Rating": 3,
          "Software": 36,
          "EmployeeImg": "usermale",
          "CurrentSalary": 49040,
          "Address": "2, rue du Commerce",
          "Mail": "jack30@sample.com"
        },
        {
          "EmployeeID": 10005,
          "Employees": "Vinet Bergs",
          "Designation": "Program Directory",
          "Location": "UK",
          "Status": "Active",
          "Trustworthiness": "Insufficient",
          "Rating": 1,
          "Software": 39,
          "EmployeeImg": "usermale",
          "CurrentSalary": 5495,
          "Address": "Rua da Panificadora, 12",
          "Mail": "vinet32@jourrapide.com"
        },
        {
          "EmployeeID": 10006,
          "Employees": "Buchanan Van",
          "Designation": "Designer",
          "Location": "Germany",
          "Status": "Active",
          "Trustworthiness": "Insufficient",
          "Rating": 4,
          "Software": 78,
          "EmployeeImg": "usermale",
          "CurrentSalary": 42182,
          "Address": "24, place Kléber",
          "Mail": "buchanan18@mail.com"
        },
        {
          "EmployeeID": 10007,
          "Employees": "Dodsworth Nancy",
          "Designation": "Project Lead",
          "Location": "USA",
          "Status": "Inactive",
          "Trustworthiness": "Sufficient",
          "Rating": 0,
          "Software": 0,
          "EmployeeImg": "userfemale",
          "CurrentSalary": 35776,
          "Address": "Rua do Paço, 67",
          "Mail": "dodsworth84@mail.com"
        },
        {
          "EmployeeID": 10008,
          "Employees": "Laura Jack",
          "Designation": "Developer",
          "Location": "Austria",
          "Status": "Inactive",
          "Trustworthiness": "Perfect",
          "Rating": 3,
          "Software": 89,
          "EmployeeImg": "usermale",
          "CurrentSalary": 25108,
          "Address": "Rua da Panificadora, 12",
          "Mail": "laura82@mail.com"
        },
        {
          "EmployeeID": 10009,
          "Employees": "Anne Fuller",
          "Designation": "Program Directory",
          "Location": "Mexico",
          "Status": "Active",
          "Trustworthiness": "Insufficient",
          "Rating": 0,
          "Software": 19,
          "EmployeeImg": "userfemale",
          "CurrentSalary": 32568,
          "Address": "Gran Vía, 1",
          "Mail": "anne97@jourrapide.com"
        },
        {
          "EmployeeID": 10010,
          "Employees": "Buchanan Andrew",
          "Designation": "Designer",
          "Location": "Austria",
          "Status": "Active",
          "Trustworthiness": "Insufficient",
          "Rating": 1,
          "Software": 62,
          "EmployeeImg": "userfemale",
          "CurrentSalary": 12320,
          "Address": "P.O. Box 555",
          "Mail": "buchanan50@jourrapide.com"
        },
        {
          "EmployeeID": 10011,
          "Employees": "Andrew Janet",
          "Designation": "System Analyst",
          "Location": "Germany",
          "Status": "Active",
          "Trustworthiness": "Insufficient",
          "Rating": 3,
          "Software": 8,
          "EmployeeImg": "userfemale",
          "CurrentSalary": 20890,
          "Address": "Starenweg 5",
          "Mail": "andrew63@mail.com"
        },
        {
          "EmployeeID": 10012,
          "Employees": "Margaret Tamer",
          "Designation": "System Analyst",
          "Location": "Germany",
          "Status": "Active",
          "Trustworthiness": "Insufficient",
          "Rating": 4,
          "Software": 7,
          "EmployeeImg": "userfemale",
          "CurrentSalary": 22337,
          "Address": "Magazinweg 7",
          "Mail": "margaret26@mail.com"
        },
        {
          "EmployeeID": 10013,
          "Employees": "Tamer Fuller",
          "Designation": "CFO",
          "Location": "Canada",
          "Status": "Active",
          "Trustworthiness": "Insufficient",
          "Rating": 3,
          "Software": 78,
          "EmployeeImg": "usermale",
          "CurrentSalary": 89181,
          "Address": "Taucherstraße 10",
          "Mail": "tamer40@arpy.com"
        },
        {
          "EmployeeID": 10014,
          "Employees": "Tamer Anne",
          "Designation": "CFO",
          "Location": "Sweden",
          "Status": "Active",
          "Trustworthiness": "Sufficient",
          "Rating": 0,
          "Software": 18,
          "EmployeeImg": "usermale",
          "CurrentSalary": 20998,
          "Address": "Taucherstraße 10",
          "Mail": "tamer68@arpy.com"
        },
        {
          "EmployeeID": 10015,
          "Employees": "Anton Davolio",
          "Designation": "Project Lead",
          "Location": "France",
          "Status": "Active",
          "Trustworthiness": "Sufficient",
          "Rating": 4,
          "Software": 8,
          "EmployeeImg": "userfemale",
          "CurrentSalary": 48232,
          "Address": "Luisenstr. 48",
          "Mail": "anton46@mail.com"
        },
        {
          "EmployeeID": 10016,
          "Employees": "Buchanan Buchanan",
          "Designation": "System Analyst",
          "Location": "Austria",
          "Status": "Inactive",
          "Trustworthiness": "Perfect",
          "Rating": 0,
          "Software": 19,
          "EmployeeImg": "usermale",
          "CurrentSalary": 43041,
          "Address": "Carrera 52 con Ave. Bolívar #65-98 Llano Largo",
          "Mail": "buchanan68@mail.com"
        },
        {
          "EmployeeID": 10017,
          "Employees": "King Buchanan",
          "Designation": "Program Directory",
          "Location": "Sweden",
          "Status": "Active",
          "Trustworthiness": "Sufficient",
          "Rating": 0,
          "Software": 44,
          "EmployeeImg": "userfemale",
          "CurrentSalary": 25259,
          "Address": "Magazinweg 7",
          "Mail": "king80@jourrapide.com"
        },
        {
          "EmployeeID": 10018,
          "Employees": "Rose Michael",
          "Designation": "Project Lead",
          "Location": "Canada",
          "Status": "Active",
          "Trustworthiness": "Perfect",
          "Rating": 4,
          "Software": 31,
          "EmployeeImg": "userfemale",
          "CurrentSalary": 91156,
          "Address": "Fauntleroy Circus",
          "Mail": "rose75@mail.com"
        },
        {
          "EmployeeID": 10019,
          "Employees": "King Bergs",
          "Designation": "Developer",
          "Location": "Germany",
          "Status": "Active",
          "Trustworthiness": "Sufficient",
          "Rating": 2,
          "Software": 29,
          "EmployeeImg": "userfemale",
          "CurrentSalary": 28826,
          "Address": "2817 Milton Dr.",
          "Mail": "king57@jourrapide.com"
        },
        {
          "EmployeeID": 10020,
          "Employees": "Davolio Fuller",
          "Designation": "Designer",
          "Location": "Canada",
          "Status": "Inactive",
          "Trustworthiness": "Sufficient",
          "Rating": 3,
          "Software": 35,
          "EmployeeImg": "userfemale",
          "CurrentSalary": 71035,
          "Address": "Gran Vía, 1",
          "Mail": "davolio29@arpy.com"
        },
        {
          "EmployeeID": 10021,
          "Employees": "Rose Rose",
          "Designation": "CFO",
          "Location": "Germany",
          "Status": "Active",
          "Trustworthiness": "Perfect",
          "Rating": 3,
          "Software": 38,
          "EmployeeImg": "usermale",
          "CurrentSalary": 68123,
          "Address": "Rua do Mercado, 12",
          "Mail": "rose54@arpy.com"
        },
        {
          "EmployeeID": 10022,
          "Employees": "Andrew Michael",
          "Designation": "Program Directory",
          "Location": "UK",
          "Status": "Inactive",
          "Trustworthiness": "Insufficient",
          "Rating": 2,
          "Software": 61,
          "EmployeeImg": "userfemale",
          "CurrentSalary": 75470,
          "Address": "2, rue du Commerce",
          "Mail": "andrew88@jourrapide.com"
        },
        {
          "EmployeeID": 10023,
          "Employees": "Davolio Kathryn",
          "Designation": "Manager",
          "Location": "Germany",
          "Status": "Active",
          "Trustworthiness": "Perfect",
          "Rating": 3,
          "Software": 25,
          "EmployeeImg": "usermale",
          "CurrentSalary": 25234,
          "Address": "Hauptstr. 31",
          "Mail": "davolio42@sample.com"
        },
        {
          "EmployeeID": 10024,
          "Employees": "Anne Fleet",
          "Designation": "System Analyst",
          "Location": "UK",
          "Status": "Active",
          "Trustworthiness": "Perfect",
          "Rating": 3,
          "Software": 0,
          "EmployeeImg": "userfemale",
          "CurrentSalary": 8341,
          "Address": "59 rue de lAbbaye",
          "Mail": "anne86@arpy.com"
        },
        {
          "EmployeeID": 10025,
          "Employees": "Margaret Andrew",
          "Designation": "System Analyst",
          "Location": "Germany",
          "Status": "Inactive",
          "Trustworthiness": "Insufficient",
          "Rating": 3,
          "Software": 51,
          "EmployeeImg": "userfemale",
          "CurrentSalary": 84975,
          "Address": "P.O. Box 555",
          "Mail": "margaret41@arpy.com"
        },
        {
          "EmployeeID": 10026,
          "Employees": "Kathryn Laura",
          "Designation": "Project Lead",
          "Location": "Austria",
          "Status": "Active",
          "Trustworthiness": "Insufficient",
          "Rating": 3,
          "Software": 48,
          "EmployeeImg": "usermale",
          "CurrentSalary": 97282,
          "Address": "Avda. Azteca 123",
          "Mail": "kathryn82@rpy.com"
        },
        {
          "EmployeeID": 10027,
          "Employees": "Michael Michael",
          "Designation": "Developer",
          "Location": "UK",
          "Status": "Inactive",
          "Trustworthiness": "Perfect",
          "Rating": 4,
          "Software": 16,
          "EmployeeImg": "usermale",
          "CurrentSalary": 4184,
          "Address": "Rua do Paço, 67",
          "Mail": "michael58@jourrapide.com"
        },
        {
          "EmployeeID": 10028,
          "Employees": "Leverling Vinet",
          "Designation": "Project Lead",
          "Location": "Germany",
          "Status": "Inactive",
          "Trustworthiness": "Perfect",
          "Rating": 0,
          "Software": 57,
          "EmployeeImg": "userfemale",
          "CurrentSalary": 38370,
          "Address": "59 rue de lAbbaye",
          "Mail": "leverling102@sample.com"
        },
        {
          "EmployeeID": 10029,
          "Employees": "Rose Jack",
          "Designation": "Developer",
          "Location": "UK",
          "Status": "Active",
          "Trustworthiness": "Perfect",
          "Rating": 0,
          "Software": 46,
          "EmployeeImg": "userfemale",
          "CurrentSalary": 84790,
          "Address": "Rua do Mercado, 12",
          "Mail": "rose108@jourrapide.com"
        },
        {
          "EmployeeID": 10030,
          "Employees": "Vinet Van",
          "Designation": "Developer",
          "Location": "USA",
          "Status": "Active",
          "Trustworthiness": "Sufficient",
          "Rating": 0,
          "Software": 40,
          "EmployeeImg": "usermale",
          "CurrentSalary": 71005,
          "Address": "Gran Vía, 1",
          "Mail": "vinet90@jourrapide.com"
        }
      ]
});

Limitations

  • Inserting multiple hyperlinks after selecting multiple ranges is not supported in Hyperlink.

See Also