mapbox / dbf

dbf writer
BSD 2-Clause "Simplified" License
37 stars 56 forks source link

save on browser #29

Closed fcpauldiaz closed 5 years ago

fcpauldiaz commented 6 years ago

How do I save the dbf file on the browser?

MammutAlex commented 5 years ago

You can use saveAs libe or write in vanillajs

saveAs example

 saveAs(new Blob([toBuffer(dbf.structure(data).buffer)], {
    type: "application/x-dbf;charset=utf-8"
}), 'data.dbf');

vanillajs example

var element = document.createElement('a');
element.setAttribute('href', 
    'data:application/x-dbf;charset=utf-8,' + toBuffer(dbf.structure(data).buffer)
);
element.setAttribute('download', 'data.dbf');
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
fcpauldiaz commented 5 years ago

Nice