Answer the question
In order to leave comments, you need to log in
How to export html to excel with js(UTF-8 REQUIRED)?
There is this code
var data_type = 'data:application/vnd.ms-excel/charset=UTF-8';
var tables_divs_sum_html = '<table border=1 ><tbody ><tr border=1 ><td border=1 >';
var table_divs = document.getElementsByClassName('calculate--container')
for(let i=0;i<table_divs.length;i++){
if(i === table_divs.length - 1){
tables_divs_sum_html += table_divs[i].outerHTML+'</td></tr></tbody></table>';
} else {
tables_divs_sum_html += table_divs[i].outerHTML+'</td><td>';
}
}
var table_html = tables_divs_sum_html.replace(/ /g, '%20');
var a = document.createElement('a');
a.href = data_type + ', ' + table_html
a.download = `Report_for_${this.props.match.params.month}_${this.props.match.params.year}`+'.xls';
a.click();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question