最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - xlxs.js how does the "l" cell hyperlink object option work - Stack Overflow

programmeradmin0浏览0评论

Im currently using the following library to make excel documents .md

right now two of my cells look like this

ws[XLSX.utils.encode_cell({c: 0, r: 1})] = {v: "Report Url", s: {font : {sz : "11", bold : true}}}
ws[XLSX.utils.encode_cell({c: 1, r: 1})] = {v: self.url, s: {font : {sz : "11"}}}

Which yield a row with: "Report Url" | ::really long ugly url::

The Documentation says there is an "l" option But gives no documentation as to how to use it. In README:

Cell object:

'::l:: cell hyperlink object (.Target holds link, .tooltip is tooltip)'

Does anyone have an exp with it, I'd like the excel to have a row with just one column that says "report url" and it would be a clickable link

All the things I tried that failed:

ws[XLSX.utils.encode_cell({c: 0, r: 1})] = {l: self.url, s: {font : {sz : "11", bold : true}}}
ws[XLSX.utils.encode_cell({c: 0, r: 1})] = {v: "url", l: self.url, s: {font : {sz : "11", bold : true}}}
ws[XLSX.utils.encode_cell({c: 0, r: 1})] = {v: Target,l: {Target :self.url}, s: {font : {sz : "11", bold : true}}}
ws[XLSX.utils.encode_cell({c: 0, r: 1})] = {l: {Target :self.url}, s: {font : {sz : "11", bold : true}}}

Any Ideas?

Im currently using the following library to make excel documents https://github./SheetJS/js-xlsx/blob/master/README.md

right now two of my cells look like this

ws[XLSX.utils.encode_cell({c: 0, r: 1})] = {v: "Report Url", s: {font : {sz : "11", bold : true}}}
ws[XLSX.utils.encode_cell({c: 1, r: 1})] = {v: self.url, s: {font : {sz : "11"}}}

Which yield a row with: "Report Url" | ::really long ugly url::

The Documentation says there is an "l" option But gives no documentation as to how to use it. In README:

Cell object:

'::l:: cell hyperlink object (.Target holds link, .tooltip is tooltip)'

Does anyone have an exp with it, I'd like the excel to have a row with just one column that says "report url" and it would be a clickable link

All the things I tried that failed:

ws[XLSX.utils.encode_cell({c: 0, r: 1})] = {l: self.url, s: {font : {sz : "11", bold : true}}}
ws[XLSX.utils.encode_cell({c: 0, r: 1})] = {v: "url", l: self.url, s: {font : {sz : "11", bold : true}}}
ws[XLSX.utils.encode_cell({c: 0, r: 1})] = {v: Target,l: {Target :self.url}, s: {font : {sz : "11", bold : true}}}
ws[XLSX.utils.encode_cell({c: 0, r: 1})] = {l: {Target :self.url}, s: {font : {sz : "11", bold : true}}}

Any Ideas?

Share Improve this question asked Sep 9, 2015 at 17:02 lonewarrior556lonewarrior556 4,4792 gold badges32 silver badges58 bronze badges 3
  • Have you solved this issue? I'm stuck with same right now. – dr.dimitru Commented Nov 29, 2015 at 0:17
  • As Far as I can tell it is not supported. I think the 'l' is only for reading xl docs not writing to them. – lonewarrior556 Commented Nov 30, 2015 at 19:30
  • I guess so also. So gave up on XLS at this point and simply moved to RTF – dr.dimitru Commented Nov 30, 2015 at 20:40
Add a ment  | 

2 Answers 2

Reset to default 11

It is currently not implemented. See open issue.

An other approach would be to use a hyperlink formula like this

ws[XLSX.utils.encode_cell({
    c: 0,
    r: 0
})] = {
    f: '=HYPERLINK("http://www.google.","Google")'
};

to achieve the same thing as soon as the preventing issue is fixed. This patch and the other one sadly didn't work for me.

I had a similar issue, wanting to link all rows in column one (except the first that is the header) with a custom link. What I did was the following (json is my array for the excel file while links is an array containig the link for each row):

const worksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(json);
for (let i = 1; i < json.length + 1; i++) {
    worksheet[XLSX.utils.encode_cell({
      c: 1,
      r: i
    })].l = { Target: links[i-1] };
}

That had as a result an excel file with the second column having internal custom links

发布评论

评论列表(0)

  1. 暂无评论