Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/segment-boneyard/google-spreadsheets
A nicer Google Spreadsheets API for node.
https://github.com/segment-boneyard/google-spreadsheets
Last synced: about 5 hours ago
JSON representation
A nicer Google Spreadsheets API for node.
- Host: GitHub
- URL: https://github.com/segment-boneyard/google-spreadsheets
- Owner: segment-boneyard
- Created: 2013-12-16T07:34:03.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-10T19:14:04.000Z (almost 10 years ago)
- Last Synced: 2024-04-09T16:31:05.366Z (7 months ago)
- Language: JavaScript
- Size: 170 KB
- Stars: 51
- Watchers: 39
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# Google Spreadsheets
A nicer Google Spreadsheets API for node. Supports batched reads and writes.
## Installation
$ npm install segmentio/google-spreadsheets
## Examples
### Open Spreadsheet
```js
var spreadsheets = require('google-spreadsheets');spreadsheets()
.login('username', 'password')
.key('0AvP3ixW_RotVdHdnWDZvUHhnWWhHQy0xZFViN3hUSmc')
.open(function (err, spreadsheet) {});
``````js
spreadsheets()
.login('username', 'password')
.name('Segment.io Users')
.open(function (err, spreadsheet) {
});
```### Select Worksheet
```js
var sheet = spreadsheet.select('id');
```or full example:
```js
spreadsheets()
.login('username', 'password')
.key('0AvP3ixW_RotVdHdnWDZvUHhnWWhHQy0xZFViN3hUSmc')
.open(function (err, spreadsheet) {
var worksheets = spreadsheet.worksheets;
var worksheet = spreadsheet.select(worksheets[0].id);
console.log(worksheet);
/*
{
id: 'od6',
name: 'Sheet1',
columnCount: 20,
rowCount: 20
}
*/
});
```### Get Cells
```js
worksheet.query()
.cell(1, 1)
.cell(1, 2)
.get(function (err, cells) {
console.log(cells);
// [
// {row: 1, column: 1, value: 'something', text: 'something'},
// {row: 1, column: 2, value: '=R[-1]C/12', text: '$18233.33', numeric: 18233.33 }
// ]
});
```### Update Rows
```js
worksheet.update()
.cell(1, 3, 'hello')
.cell(1, 4, 'hello2')
.send(function (err) {
});
```### Query Worksheet Metadata
```js
worksheet.metadata(function (err, metadata) {
console.log(metadata);
/*
{
id: 'od6',
name: 'Sheet1',
columnCount: 20,
rowCount: 20
}
*/
});
```## API
### Spreadsheets
#### .login(username, password)
Adds a client-login authentication password for the Google Spreadsheets service.
#### .key(key)
Creates an open query for a spreadsheet with `key`.
#### .name(name)
Creates an open query for a spreadsheet with `name`.
#### .open(callback)
Executes the spreadsheet open query.
### Spreadsheet
#### .worksheets
An array of worksheets accessible on the spreadsheet.
#### .select(id)
Return a worksheet with `id` within the spreadsheet.
### Worksheet
#### .query()
Creates a worksheet `CellQuery`.
#### .update()
Creates a worksheet `UpdateQuery`.
#### .metadata(callback)
Queries for a worksheet's metadata.
### CellQuery
#### .cell(row, column)
Adds a cell to lookup within the `CellQuery`.
#### .get(callback)
Executes the `CellQuery`.
### UpdateQuery
#### .cell(row, column, val)
Adds a cell to update to the batch update query.
#### .send(callback)
Sends the cell update batch query.
## License
```
WWWWWW||WWWWWW
W W W||W W W
||
( OO )__________
/ | \
/o o| MIT \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|
```