Closed rsmartins78 closed 5 years ago
Hey , use this npm install --save angular5-csv for export , I am using this and working fine
As I said, I'm still learning. So in the example presented, I can create a button that calls a function and in this function I'll put this "new Angular5Csv(data, 'My Report');" ??
Thank you for the attention and sorry for my english.
i did like this
public downloadCsv() {
const options = {
fieldSeparator: ',',
quoteStrings: '"',
decimalseparator: '.',
showLabels: true,
showTitle: true,
headers: ['ID', 'Seller Name', 'User Name', 'Email','Date']
};
this.MYfile = new Angular5Csv(this.data, 'Report', options);
}
Thank you, I'll test it
To add on what @Anujmoglix said; You can also get it done this way after having declared table source with LocalDataSource type:
downloadCSV() {
const options = {
fieldSeparator: ',',
quoteStrings: '"',
decimalseparator: '.',
showLabels: true,
showTitle: true,
useBom: true,
headers: [
'id',
'numero',
'objet',
],
};
this.source.getAll().then(data => {
new Angular5Csv(data, 'report', options);
})
}
FYI If you want to export just filtered data, then use
this.source.getFilteredAndSorted()
Is there any way to export screen data (with and without applied filters) to XLS or CSV file?
I'm migrating an old application from ExtJS3.4 to Angular, however I'm still learning Angular.
I was able to create my table with ng2-smart-table successfully, but I'm thinking how to export the data, because in the old tool, I made a call to an export.php that makes a query in the database and exports to XLS.
Thank you for your attention.
Sorry for my English.