SheetJS / sheetjs

📗 SheetJS Spreadsheet Data Toolkit -- New home https://git.sheetjs.com/SheetJS/sheetjs
https://sheetjs.com/
Apache License 2.0
34.96k stars 8k forks source link

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

Closed NicolasBrawerman closed 2 years ago

NicolasBrawerman commented 3 years ago

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 2 years ago

18ce6212c44c1d558a47410112e9bfecec27f44d