Export Hyperlink from html table to XLSX with sheets js #2188

Closed
opened 2020-11-25 12:25:39 +00:00 by NicolasBrawerman · 1 comment
NicolasBrawerman commented 2020-11-25 12:25:39 +00:00 (Migrated from github.com)

Hi
i have an html table with an hyperlink field, when trying to export to xlsx the hyperlink become plain text.
try to find some info in the web or some examples without success -
if possible to provide an example it can be great -

attached some source code :
my defectsTable hyperlink:

<td> <a target="_blank" href=anyLink>1157253</a></td>

export to xlsx :
`function runXLSX() {

        var wb = XLSX.utils.table_to_book(document.getElementById('defectsTable'), { sheet: "Inconsistencies" });

        wb.SheetNames.push("Per Team");
         
        var ws2 = XLSX.utils.table_to_sheet(document.getElementById('perTeamTable'));

        wb.Sheets["Per Team"] = ws2;
           var wbout = XLSX.write(wb, {bookType:'xlsx', bookSST:true, type: 'binary'});
        saveAs(new Blob([s2ab(wbout)], { type: "application/octet-stream" }), 'DefectInco.xlsx');
                   

        }

function s2ab(s) {
var buf = new ArrayBuffer(s.length);
var view = new Uint8Array(buf);
for (var i=0; i<s.length; i++) view[i] = s.charCodeAt(i) & 0xFF;
return buf;
}
`

Hi i have an html table with an hyperlink field, when trying to export to xlsx the hyperlink become plain text. try to find some info in the web or some examples without success - if possible to provide an example it can be great - attached some source code : my **defectsTable** hyperlink: `<td> <a target="_blank" href=anyLink>1157253</a></td>` export to xlsx : `function runXLSX() { var wb = XLSX.utils.table_to_book(document.getElementById('defectsTable'), { sheet: "Inconsistencies" }); wb.SheetNames.push("Per Team"); var ws2 = XLSX.utils.table_to_sheet(document.getElementById('perTeamTable')); wb.Sheets["Per Team"] = ws2; var wbout = XLSX.write(wb, {bookType:'xlsx', bookSST:true, type: 'binary'}); saveAs(new Blob([s2ab(wbout)], { type: "application/octet-stream" }), 'DefectInco.xlsx'); } function s2ab(s) { var buf = new ArrayBuffer(s.length); var view = new Uint8Array(buf); for (var i=0; i<s.length; i++) view[i] = s.charCodeAt(i) & 0xFF; return buf; } `
SheetJSDev commented 2021-09-18 21:47:28 +00:00 (Migrated from github.com)
18ce6212c44c1d558a47410112e9bfecec27f44d
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#2188
No description provided.