0.3.0 • Published 7 years ago

google-spreadsheet-promise v0.3.0

Weekly downloads
56
License
MIT
Repository
github
Last release
7 years ago

google-spreadsheet-promise

A light-weight promise wrapper around NPM google-spreadsheet.

Helpful link on limits of Google spreadsheets.

Usage

const gsp = require('google-spreadsheet-promise')

// a spreadsheet key is the long id in the sheets URL
const key = '1fyGsYhinmTRNpJyw_uVDpI3wYmWz9FXIYgR2DuobZ_w'
// see Auth help/tips below
const credsPath = './google-generated-creds.json'

. . .

// Note- assumed to be in a generator for "yield":
const sheets = yield gsp.init(key, credsPath)


// Syntax #1: any-sheet syntax:
const sheetsInfo = yield sheets.getInfo()
const headerRow = yield sheets.getHeaderRow(1) // 1-based indexing of sheets
const rows = yield sheets.getRows(1)
const cells = yield sheets.getCells(1)
const data = yield sheets.addRow(1, {
   col1Name: Math.random(),
   col2Name: Date.now()
})
yield sheets.del(sheetNumber)


// Syntax #2: single-sheet syntax:
const sheetOne = sheets.sheetNumber(1) // 1-based indexing of sheets

const sheetOneInfo = yield sheetOne.getInfo()
const headerRow = yield sheetOne.getHeaderRow()
const rows = yield sheetOne.getRows()
const cells = yield sheetOne.getCells()
const data = yield sheetOne.addRow({
   col1Name: Math.random(),
   col2Name: Date.now()
})
yield sheetOne.del()

Full list of promisified functions

* Note: Returned rows and cells have a .promise property added to them, where .save(), .del(), etc are found. This helps maintain API compatibilities, including bulkUpdateCells().

Notes

See test/test.js for other examples.

See google-spreadsheet for more options.

Auth help/tips.

0.3.0

7 years ago

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago