I found a solution in the link:
Encoding UTF-8 when exporting HTML table to Excel
and it works and all my unicode data saved correctly in the excel file. But I changed it a little because I wanted to use a given filename then I used an anchor tag instead of window.open, that dynamically added to the document and after clicking on, will be removed. Then it looks like below:
function exportExcel(tableText, filename, worksheetName) {
let downloadLink = document.createElement("a");
let 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>' + tableText + '</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]; }) }
let ctx = { worksheet: worksheetName || 'Worksheet', table: tableText }
// window.location.href = uri + base64(format(template, ctx));
downloadLink.href = uri + base64(format(template, ctx));
downloadLink.download = (filename||"exportedTable") + ".xls";
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
}
and finally you can call this function with your data:
exportExcel(anyHtmlTableText, "myFileName","mySheetName");