Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

162
Views
In-browser Sheet.js code generating corrupt .xlsx file. What's wrong with my code?
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.2/xlsx.min.js"> </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.0/FileSaver.min.js"> </script>

<script>
    var wb = XLSX.utils.book_new(); 
    
    $('.special-table').each(function(i,item){
        var table_id = $(this).attr('id')
        var sheet_name = table_id.replace('-table','')
        console.log(table_id);
        wb.SheetNames.push(sheet_name)
        var ws = XLSX.utils.table_to_sheet(document.getElementById(table_id));
        wb.Sheets[sheet_name] = ws;
    })

    var wbout = XLSX.write(wb, {bookType:'xlsx', bookSST:true, type: 'binary'});
    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;
    }
    $("#download").click(function(){
        saveAs(new Blob([s2ab(wbout)],{type:"application/octet-stream"}), 'ppe_report.xlsx');
    });

</script>

I followed the guide here: https://redstapler.co/sheetjs-tutorial-html-table-to-excel/

As the title states, this is in-browser. Can anyone help? Any help or advice is appreciated, right now I am scratching my head. Thanks in advance

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I needed to use xlsx.full.min.js, not xlsx.min.js

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!