I have created my Data table from the angular 2 website. Now I want to export my json data to PDF,excel using angular 2 framework.
Kindly give me s
I was finally used this one:
function downloadExcelFile(ev) {
connectionService.getExcelExport(function (response) {
if (response.status == 200) {
/**
* Export data to csv file
*/
let blob = new Blob([response.data], {type: 'text/csv'});
let filename = `export.csv`;
if(window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveBlob(blob, filename);
}
else{
let elem = window.document.createElement('a');
elem.href = window.URL.createObjectURL(blob);
elem.download = filename;
document.body.appendChild(elem);
elem.click();
document.body.removeChild(elem);
}
console.log(`export excel file is successful.`);
}
})
}