fileName: This is the default filename of the downloadable file.data: This is where I pass the array of data. Here I’m writing some template code to show the ‘Export to excel’ button and the data itself: Export to excel Code language: HTML, XML ( xml )Īs you can see, in the downloadFile() method, I’ve defined and initialised 3 constants: Once you’ve installed the package, you can start using it. Let’s begin.įirst of all, you’ll need to install the NPM package called export-from-json as follows: npm install export- from-json -save After that, you can use the library to convert and download the data. You can then extract the data you want from it, by probably mapping it to a new list. If you’re working on a Vue.js app, there’s a very high chance you’re dealing with JSON / JS Objects data most of the time. However, Vue comes with libraries which can handle all of it at the front-end itself. You can always create an excel / CSV file on the server and send it to the user upon request. There are multiple occasions when a user may want to export some data as a report.
0 Comments
Leave a Reply. |