javascript - Header name issue is coming in jquery export html data table downloaded excel sheet in internet explorer -
i exporting excel sheet in ie. header name not coming through correctly in downloaded sheet. in other browsers it's working fine. excel sheet header name spanish word. please on this.
$(document).ready(function() { console.log("hello") function exporttabletocsv($table, filename) { var $headers = $table.find('tr:has(th)'), $rows = $table.find('tr:has(td)'), // temporary delimiter characters unlikely typed keyboard // avoid accidentally splitting actual contents tmpcoldelim = string.fromcharcode(11), // vertical tab character tmprowdelim = string.fromcharcode(0), // null character // actual delimiter characters csv format coldelim = '","', rowdelim = '"\r\n"'; // grab text table csv formatted string var csv = '"'; csv += formatrows($headers.map(grabrow)); csv += rowdelim; csv += formatrows($rows.map(grabrow)) + '"'; // data uri var csvdata = 'data:application/csv;charset=utf-8,'+ escape(csv); //var csvdata = 'data:application/csv;charset=utf-8,' + encodeuricomponent(csv); // ie (tested 10+) if (window.navigator.mssaveoropenblob) { var blob = new blob([decodeuricomponent(encodeuri(csv))], { type: "text/csv;charset=utf-8,"+ escape(csv) }); window.navigator.mssaveblob(blob, filename); } else { $(this).attr({ 'download' : filename, 'href' : csvdata //,'target' : '_blank' //if want open in new window }); }
Comments
Post a Comment