javascript - tableToExcel jQuery throws strange error in IE -
i using jquery function export html table excel. function have seen used in plenty of other places, , works fine me in chrome:
var tabletoexcel = (function() { 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"><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>{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)) } })() however, in ie 10, line: "window.location.href = uri + base64(format(template, ctx))" - throwing error: "script122: data area passed system call small."
i've done bit of research , seems ie not able handle length of uri reason. there workarounds?
you friend in big trouble ( kidding )!
the main issue older versions of ie support base64 encoding can taken care of using this javascript library.
but main issue data url scheme available on webkit based browsers , can have on ie based on rca 2397. has limited functionality , works images , css. here useful link. make sure read wikipedia page data url scheme
**now talk workarounds! **
the main solution writing server side script creates excel file , use ajax call send user! can store file on server's filesystem , send address of file.
though if focusing on client side , need work on ie, should use download library, preferably ones have swf (flash support) here 1 have not used yet, though hoping result looking for. there claims downloadify , let me know how goes!
Comments
Post a Comment