I have the following function that exports an html to excel:
function generateexcel(tableid) {
var table= document.getElementById(tableid);
var html = ta
Replacing chars is a poor solution.
I replaced encodeURIComponent for escape and works fine, but escape is deprecated since ECMAScript v3.
This issue occurs because encodeURIComponent works with UTF-8 and Excel does not.
Better way for me.
Encode data to base64 and export like this. I used jquery-base64 plugin from https://github.com/carlo/jquery-base64/blob/master/jquery.base64.min.js
And change code to:
window.open('data:application/vnd.ms-excel;base64,' + $.base64.encode(html));
If you don't want to use jquery, you can use this base64_encode function http://phpjs.org/functions/base64_encode
"Base64 encoding/decoding is already a native function in modern(tm) browsers: btoa(str) and atob(str) are the functions that should can be used without any external reimplementation." - chipairon