javascript - Export large html table to excel -


i want export html table excel i'm using javascript code:

var tabletoexcel = (function () {         var tds = document.getelementsbytagname("td");          var uri = 'data:application/vnd.ms-excel;base64,'                 , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/tr/rec-html40"><meta http-equiv="content-type" content="application/vnd.ms-excel; charset=utf-8"><head><!--[if gte mso 9]><xml><x:excelworkbook><x:excelworksheets><x:excelworksheet><x:name>{worksheet}</x:name><x:worksheetoptions><x:displaygridlines/></x:worksheetoptions></x:excelworksheet></x:excelworksheets></x:excelworkbook></xml><![endif]--></head><body><table x:str>{table}</table></body></html>'                 , 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))         }     })(); 

at first,this code work fine form me ,but in large table not because uri long window.location.href. soution export large table excel ?

i found 1 way solve issue using filesaver.js 1: https://github.com/eligrey/filesaver.js/ please check followings

html enter image description here

javascript

enter image description here

this working fine me large data set of html table.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -