Export to excel functionality in simplifier
-
Shivam3 years ago #24032
Hello simplifier community,
I am working on some tables in my mobile application. On click of a button, all I want is that the the data from the table should be exported to an excel file like pdf. can it be implemented in simplifier ? If yes, then how can it be implemented ? Suggest me a solution for this. Thanks in advance.
Regards,
Shivam Gupta
Jennifer HäfnerHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)Has successfully completed the online course Advanced (310)Has successfully completed the online course Advanced (320)Has successfully completed the Intermediate CertificationHas successfully completed the Advanced Certification3 years ago #24034::Hi Shivam,
In general, to export data in csv format, you have to convert the json model data from your table to csv format (text separated by semicolons), then create a blob file and save it.
Here is one example how to do this:
Step 1) Convert json model data of table to csv format using the Papa Parse library:
var oJsonData = this.getGlobals().getVar(“oTableData”); //the json model of your table
var oCsvData = Papa.unparse(oJsonData);Step 2) Create blob file and save it:
//download csv file
var oBlob = new Blob([oCsvData], {
type: ‘text/csv;charset=utf-8;’
});
saveAs(oBlob, “my.csv”);In the Papa Parse documentation, you can find more options to format json to csv: https://www.papaparse.com/
Jennifer HäfnerHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)Has successfully completed the online course Advanced (310)Has successfully completed the online course Advanced (320)Has successfully completed the Intermediate CertificationHas successfully completed the Advanced Certification3 years ago #24087::Since you also can open .csv files in Excel (using the correct delimiter), we usually implement an excel export like in my example above.
If you have to export an .xls file, you can take a look at javascript libraries that export data in the required format, like https://sheetjs.com/opensource.
You must be logged in to reply to this topic.