JourneyApps Legacy Docs
Return to JourneyApps Docs
  • UI Components
    • button (v1) (deprecated)
    • button (v2) (deprecated)
    • capture-coordinates (legacy docs)
    • capture-file (legacy docs)
    • capture-signature (legacy docs)
    • display-file (legacy docs)
    • display-signature (legacy docs)
    • info-table (legacy docs)
    • list (legacy docs)
    • menu (deprecated)
    • object-dropdown (legacy docs)
    • object-table (v1) (deprecated)
    • object-table (v2) (deprecated)
    • scan-barcode (legacy docs)
    • single-choice-dropdown (legacy docs)
  • JS/TS APIs
    • dialog (deprecated)
    • confirmDialog (deprecated)
    • generateCSV (deprecated)
    • saveFile (deprecated)
  • Other Features
    • Access Control Rules (deprecated)
    • Global View (app.xml) (deprecated)
    • Linking Views (deprecated)
    • Sync Rules v1 (deprecated)
  • Sync Rules v2 (legacy docs)
    • Migrating to Sync Rules v2
  • Manage App Users (deprecated)
Powered by GitBook
On this page
  • Format
  • Examples
  1. JS/TS APIs

generateCSV (deprecated)

PreviousconfirmDialog (deprecated)NextsaveFile (deprecated)

Last updated 2 years ago

generateCSV was deprecated in version 4.28.0 of the JourneyApps Container and replaced with .

Version compatibility

generateCSV was introduced in version 4.25.0 of the JourneyApps Container.

Format

generateCSV(source, options);
Parameter
Details

source

One of:

  • Array

  • Matrix (array of arrays)

options (Optional)

Object with the following properties:

  • heading: Array of column headings

  • delimiter: Character to separate columns with.

Defaults to ,

Returns: the generated CSV as a string.

Examples

main.js
var mx = [['Cell Phone', 'Black'], ['Computer','Red']];
var csv_file.csv = generateCSV(mx, { heading: ['Type', 'Color'] } );

In this case, csv_file is:

csv_file.csv
Type,Color
Cell Phone,Black
Computer,Red

Suppose we have an asset data model object with (amongst others) name and cost as fields, and we want to generate CSV for all assets and their names and costs:

main.js
var allAssets = DB.asset.all().toArray();

var myMx = allAssets.map(function(asset) {
    return [asset.name, asset.cost];
});

var csv = generateCSV(myMx, {heading: ['Name', 'Cost']});
CSV