I have an expandable table in html:
How can I convert it into excel file with grouping, something like this:
I have an expandable table in html:
How can I convert it into excel file with grouping, something like this:
Im not to sure about the grouping in XLS but the main way we convert data into XL is to use CSV
You can parse the data from your HTML into an array then export that array to CSV
Here is the code to make your html table downloadable to CSV
var data = [
['Foo', 'programmer'],
['Bar', 'bus driver'],
['Moo', 'Reindeer Hunter']
];
function download_csv() {
var csv = 'Name,Title\n';
data.forEach(function(row) {
csv += row.join(',');
csv += "\n";
});
console.log(csv);
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);
hiddenElement.target = '_blank';
hiddenElement.download = 'people.csv';
hiddenElement.click();
}
<button onclick="download_csv()">Download CSV</button>