Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
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 Respuestas
Responde la pregunta

0

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

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda