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
javascript
this working fine me large data set of html table.
Comments
Post a Comment