react-csv-formatter
v1.0.4
Published
all csv downloader
Downloads
1
Maintainers
Readme
Getting started
Format your data as standard CSV.
Generate a CSV file from given data.
You will need four arguments to be passed in function named
formatAsCsv.
- Data as array of objects.
- Fields name in array format.
- Csv file name.
- Header name for csv file in array format.
Installation
Add formatAsCsv to your project by executing npm install react-csv-formatter
or yarn add react-csv-formatter
.
Sample Example.
Usage
Here's an example of basic usage:
import formatAsCsv from "react-csv-formatter";
let data = [ { "bio": "",company: "", designation: "", email:
"[email protected]",interested_in: "", name: "Ashish Ranjan", phone_number:
"1234567899", profile_image: null, profile_image_id: "", profile_image_url: "",
purpose: "attend", uid: "633b7f6a-48b6-48ee-b871-cb3c832a42a7" }, { bio: "",
company: "TESLA", designation: "CEO", email: "[email protected]", interested_in:
"", name: "Vijay Sirra", phone_number: "1234567890", profile_image: null,
profile_image_id: "f426939e-62c5-4ed7-b176-1b65b259e46e", profile_image_url: "",
purpose: "attend", uid: "73ab399c-985e-4a8b-b9c4-fbad2fc9b65b" } ],
let
fieldsNameToBeDisplayed=["uid","name","email","bio","phone_number","company","designation","interested_in","purpose","Age"];
let fileName="dataAsCsv";
let headerName=["Uid","Name","Email","Bio","Phone Number","Company","Designation","Interested In","Purpose","Age"];
formatAsCsv(data,fieldsNameToBeDisplayed,fileName,headerName);