Generate excel sheet from html tables using jquery

后端 未结 4 722
走了就别回头了
走了就别回头了 2020-12-01 15:41

I wanted to generate an excel sheet once a user clicks on a button . Basically i want to do exactly what is dicussed here

how to pass html table values to excel she

4条回答
  •  无人及你
    2020-12-01 16:01

    Here is the answer: Export dynamic html table to excel in javascript in firefox browser by insin

    var tableToExcel = (function() {
          var uri = 'data:application/vnd.ms-excel;base64,'
            , template = '{table}
    ' , base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) } , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) } return function(table, name) { if (!table.nodeType) table = document.getElementById(table) var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML} window.location.href = uri + base64(format(template, ctx)) } })()

提交回复
热议问题