Accent error when exporting xlxs database data with javascript

Asked

Viewed 215 times

1

I am maintaining a code that reads data from a MYSQL database and via PHP transforms it into a table and with Jquery I export it with Excel document. However the accent gets all wrong for example:

Ãチrea de Atuação  Número

The code I use in Jquery is this:

$(document).ready(function(e) {
    //creating a temporary HTML link element (they support setting file names)
    var a = document.createElement('a');
    var data_type = 'data:application/x-msexcel';
    var table_div = document.getElementById('dvData');
    var table_html = table_div.outerHTML.replace(/ /g, '%20');
    a.href = data_type + ', ' + table_html;
    a.download = 'Relatorio_Diplomas_Legais.xls';
    a.click();
});

I couldn’t find the parameter to encode the text. Would anyone know what it could be?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.