1.1.16 • Published 5 years ago

object-to-google-spreadsheet v1.1.16

Weekly downloads
20
License
MIT
Repository
github
Last release
5 years ago

Transform and publish your JSON objects into a Google spreadsheet.

Installation

NPM Info

Build Status

Example usage

const O2GS = require('object-to-google-spreadsheet');
// or use 'import' to get it with types in Typescript

// load your Google service account
const creds = require('./creds');

// get your doc key from the spreadsheet's URL
const docKey = 'Y7usmqsic4djsaxXWqaaS';

const myReport = new O2GS(creds, docKey);

// The array of objects which will build the spreadsheet
const docs = [
  {
    person : "John",
    properties : { Age: 25,  Address : "16 main st." }
  },
  {
    person : "Jane",
    properties : { Age : 24, Hobbies : ["swimming", "Javascripting"]}
  }
];

// optional
const options = {
    sheetName: 'My Awesome Report',
    rowName: 'person',
    properties: 'properties',
    a1Field: 'details', 
    sort: true, 
    removeBase: false 
};

(async ()=> {
  try {
    // populate the sheet
    await myReport.push(docs, options);
  } catch(err) {
    console.log(err);
  }
})();

Example result

updated sheet

docKey

Creds

  1. Go to the Google Developers Console
  2. Select or Create Project
  3. Dashboard > Enable APIs and Services > Enable the Drive API for your project
  4. Credentials > Create Service Account Key
  5. Select Json Key type and save the downloaded json file to your project
  6. Once you have created the services account, you will have an email xxx@xxx.iam.gserviceaccount.com. Go to your Google Sheets file and shared the edit permission to the email address.
  7. For more details, please refer to https://www.npmjs.com/package/google-spreadsheet

Links

Author

Ehab Khaireldin

License

This project is licensed under the MIT License and built for OneMeter.com

1.1.16

5 years ago

1.1.15

5 years ago

1.0.15

5 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago