I am generating a table of clicks' coordinates here. Try clicking somewhere on the field, you'll understand.
Now, I want to export this table as CSV file. I need to make it work with iPad or Tablet.
Hopefully you guys can help me!
I am generating a table of clicks' coordinates here. Try clicking somewhere on the field, you'll understand.
Now, I want to export this table as CSV file. I need to make it work with iPad or Tablet.
Hopefully you guys can help me!
You need to do the following:
Convert your table contents to CSV text:
var rows = document.querySelectorAll('#table tr');
var csvText = [].map.call(rows, function(row) {
return [].map.call(row.children, function(cell) { return cell.innerText; }).join(';');
}).join('\n');
Create a Blob
from this CSV
var blob = new Blob([csvText], { type: 'text/csv' });
Download this Blob
:
var a = document.createElement('a');
a.download = 'export.csv';
a.href = URL.createObjectURL(blob);
a.click();
Blob
constructing is supported by all modern browsers, but you may want to check this compatibility table.