Nominally Patriotic Meathead

    csv-generator-client

    2.1.1 • Public • Published

    npm version CircleCI Coverage Status dependencies Codacy Badge Maintainability Greenkeeper badge Build Status Sauce Test Status

    csv-generator-client

    Library to generate downloadable csv files from client side data.

    Installing

    npm install csv-generator-client

    This package requires lodash/fp, so make sure that's available in your app.

    Usage

    import * as generator from 'csv-generator-client'
    
    let settings = {separator: '|', addQuotes: true}
    generator.download({settings, fileName, dataArray})
    
    Or
    
    var generator = require('csv-generator-client')
    // In this case the default settings are used.
    generator.download({fileName: fileName, dataArray: dataArray})
    
    

    API

    getLinkElement

    getLinkElement({settings: settings, fileName: fileName, dataArray: dataArray})

    Where settings can be:

    {
      separator: String,
      addQuotes: Boolean,
      autoDetectColumns: Boolean, // Requires an array of objects (e.g., [{name: 'Bob'}, {name: 'Joe'}])
      columnKeys: [String] // Each element is a key in the row object (e.g., 'name')
    }

    Default settings are:

    {
      separator: ',',
      addQuotes: false,
      autoDetectColumns: false,
    }

    fileName is required dataArray is required to be an array of objects if autoDetectColumns is true, otherwise an array of arrays.

    download

    download({settings: settings, fileName: fileName, dataArray: dataArray})

    Where settings can be:

    {
      separator: String,
      addQuotes: Boolean,
      autoDetectColumns: Boolean, // Requires an array of objects (e.g., [{name: 'Bob'}, {name: 'Joe'}])
      columnKeys: [String] // Each element is a key in the row object (e.g., 'name')
    }

    Default settings are:

    {
      separator: ',',
      addQuotes: false,
      autoDetectColumns: false,
    }

    fileName is required dataArray is required to be an array of objects if autoDetectColumns is true, otherwise an array of arrays.

    Credits

    This implementation is based on csv-repository-client by AlexLibs

    Install

    npm i csv-generator-client

    DownloadsWeekly Downloads

    580

    Version

    2.1.1

    License

    MIT

    Unpacked Size

    75.4 kB

    Total Files

    16

    Last publish

    Collaborators

    • sp-dev