Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
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 Respostas
Responde à pergunta

0

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

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda