How to create internal links #685

Closed
opened 2017-06-13 01:38:57 +00:00 by gawi · 5 comments
gawi commented 2017-06-13 01:38:57 +00:00 (Migrated from github.com)

I'm trying to generate an XLSX Excel document with JS-XLSX and I can't find a way to create the equivalent of an internal link.

I have this summary page in which I'd like to present clickable links pointing to other sheets.

image

I've tried many combination of cell = {l: {Target: "..", Rel: {Target: "...", Type:"Internal"}}} but it doesn't work. It always ends up as an external hyperlink in the generated document.

I'm using JS-XLSX 0.10.4.

Is this a supported use case?

I'm trying to generate an XLSX Excel document with JS-XLSX and I can't find a way to create the equivalent of an internal link. I have this summary page in which I'd like to present clickable links pointing to other sheets. ![image](https://user-images.githubusercontent.com/813371/27062193-57543610-4fb7-11e7-8f21-27b79d26c879.png) I've tried many combination of cell = {l: {Target: "..", Rel: {Target: "...", Type:"Internal"}}} but it doesn't work. It always ends up as an external hyperlink in the generated document. I'm using JS-XLSX 0.10.4. Is this a supported use case?
SheetJSDev commented 2017-06-13 02:42:08 +00:00 (Migrated from github.com)

As a general rule, everything is in the README. If it's not mentioned there, it's either currently unsupported or a bug in the README.

The write logic currently assumes an external hyperlink for every link and every relationship, so at the moment it is not supported. It's relatively simple to fix, we'll try to roll out something in the next release. We will have to add a new flag to the link object.

As a general rule, everything is in the README. If it's not mentioned there, it's either currently unsupported or a bug in the README. The write logic currently assumes an external hyperlink for [every link](https://github.com/SheetJS/js-xlsx/blob/master/bits/67_wsxml.js#L467) and every relationship, so at the moment it is not supported. It's relatively simple to fix, we'll try to roll out something in the next release. We will have to add a new flag to the link object.
calbertts commented 2017-06-30 12:16:25 +00:00 (Migrated from github.com)

Would be great to have this feature and also the ability to add VBA code.

Would be great to have this feature and also the ability to add VBA code.
UzverNumber47 commented 2017-07-24 20:28:20 +00:00 (Migrated from github.com)

You can use formula.
sheet['A1'].f = '=HYPERLINK("#'Section1'!A1,"Section 1")';

You can use formula. sheet['A1'].f = '=HYPERLINK("#\'Section1\'!A1,"Section 1")';
SheetJSDev commented 2017-12-15 02:49:36 +00:00 (Migrated from github.com)

In the internal representation, set a cell's .l key to be an object with Target set to the reference prepended by a # e.g.

ws['A1'].l = { Target: "#Sheet2!A1" } // Link to a cell
ws['A2'].l = { Target: "#Sheet2!A1:D4" } // Link to a range
ws['A3'].l = { Target: "#SomeName" } // Link to a global or same-worksheet defined name
ws['A4'].l = { Target: "#Sheet2!SomeName" } // Link to an out-of-scope defined name

@UzverNumber47 's approach also works

In the internal representation, set a cell's `.l` key to be an object with `Target` set to the reference prepended by a `#` e.g. ```js ws['A1'].l = { Target: "#Sheet2!A1" } // Link to a cell ws['A2'].l = { Target: "#Sheet2!A1:D4" } // Link to a range ws['A3'].l = { Target: "#SomeName" } // Link to a global or same-worksheet defined name ws['A4'].l = { Target: "#Sheet2!SomeName" } // Link to an out-of-scope defined name ``` @UzverNumber47 's approach also works
charlygame commented 2021-01-07 10:30:15 +00:00 (Migrated from github.com)

ws['A1'].l = { Target: "'#SheetName'!A1" } is ok for me.

`ws['A1'].l = { Target: "'#SheetName'!A1" } ` is ok for me.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#685
No description provided.