This repository has been archived by the owner on Dec 4, 2023. It is now read-only.
forked from jpillora/node-edit-google-spreadsheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.json
30 lines (30 loc) · 8.52 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{
"name": "edit-google-spreadsheet",
"version": "0.2.6",
"dependencies": {
"async": "~0.2.9",
"colors": "~0.6.0-1",
"google-oauth-jwt": "0.0.4",
"googleclientlogin": "~0.2.6",
"lodash": "~1.2.1",
"request": "~2.21.0",
"xml2json": "^0.4.0"
},
"repository": {
"type": "git",
"url": "git://github.com/jpillora/node-edit-google-spreadsheet.git"
},
"readme": "## Edit Google Spreadsheet\n\n> A simple API for reading and writing Google Spreadsheets in Node.js\n\n[![NPM version](https://nodei.co/npm/edit-google-spreadsheet.png?compact=true)](https://npmjs.org/package/edit-google-spreadsheet)\n\n#### Install\n```\nnpm install edit-google-spreadsheet\n```\n\n#### Basic Usage\n\nLoad a spreadsheet:\n\n``` js\n var Spreadsheet = require('edit-google-spreadsheet');\n\n Spreadsheet.load({\n debug: true,\n spreadsheetName: 'node-edit-spreadsheet',\n worksheetName: 'Sheet1',\n // Choose from 1 of the 3 authentication methods:\n // 1. Username and Password\n username: '[email protected]',\n password: 'my-5uper-t0p-secret-password',\n // OR 2. OAuth\n oauth : {\n email: '[email protected]',\n keyFile: 'my-private-key.pem'\n },\n // OR 3. Token\n accessToken : {\n type: 'Bearer',\n token: 'my-generated-token'\n }\n }, function sheetReady(err, spreadsheet) {\n //use speadsheet!\n });\n```\n\n*Note: Using the options `spreadsheetName` and `worksheetName` will cause lookups for `spreadsheetId` and `worksheetId`. Use `spreadsheetId` and `worksheetId` for improved performance.*\n\nUpdate sheet:\n\n``` js\n function sheetReady(err, spreadsheet) {\n if(err) throw err;\n\n spreadsheet.add({ 3: { 5: \"hello!\" } });\n\n spreadsheet.send(function(err) {\n if(err) throw err;\n console.log(\"Updated Cell at row 3, column 5 to 'hello!'\");\n });\n }\n```\n\nRead sheet:\n\n``` js\n function sheetReady(err, spreadsheet) {\n if(err) throw err;\n\n spreadsheet.receive(function(err, rows, info) {\n if(err) throw err;\n console.log(\"Found rows:\", rows);\n // Found rows: { '3': { '5': 'hello!' } }\n });\n\n }\n```\n#### Metadata\n\nGet metadata\n\n``` js\n function sheetReady(err, spreadsheet) {\n if(err) throw err;\n \n spreadsheet.metadata(function(err, metadata){\n if(err) throw err;\n console.log(metadata);\n // { title: 'Sheet3', rowCount: '100', colCount: '20', updated: [Date] }\n });\n }\n```\n\nSet metadata\n\n``` js\n function sheetReady(err, spreadsheet) {\n if(err) throw err;\n \n spreadsheet.metadata({\n title: 'Sheet2'\n rowCount: 100,\n colCount: 20\n }, function(err, metadata){\n if(err) throw err;\n console.log(metadata);\n });\n }\n```\n\n***WARNING: all cells outside the range of the new size will be silently deleted***\n\n#### More `add` Examples\n\nBatch edit:\n\n``` js\nspreadsheet.add([[1,2,3],\n [4,5,6]]);\n```\n\nBatch edit starting from row 5:\n\n``` js\nspreadsheet.add({\n 5: [[1,2,3],\n [4,5,6]]\n});\n```\n\nBatch edit starting from row 5, column 7:\n\n``` js\nspreadsheet.add({\n 5: {\n 7: [[1,2,3],\n [4,5,6]]\n }\n});\n```\n\nFormula building with named cell references:\n``` js\nspreadsheet.add({\n 3: {\n 4: { name: \"a\", val: 42 }, //'42' though tagged as \"a\"\n 5: { name: \"b\", val: 21 }, //'21' though tagged as \"b\"\n 6: \"={{ a }}+{{ b }}\" //forumla adding row3,col4 with row3,col5 => '=D3+E3'\n }\n});\n```\n*Note: cell `a` and `b` are looked up on `send()`*\n\n#### API\n\n\n##### `Spreadsheet.load( options, callback( err, spreadsheet ) )`\n\nSee [Options](https://github.com/jpillora/node-edit-google-spreadsheet#options) below\n\n##### spreadsheet.`add( obj | array )`\nAdd cells to the batch. See examples.\n\n##### spreadsheet.`send( [options,] callback( err ) )`\nSends off the batch of `add()`ed cells. Clears all cells once complete.\n\n`options.autoSize` When required, increase the worksheet size (rows and columns) in order to fit the batch (default `false`).\n\n##### spreadsheet.`receive( [options,] callback( err , rows , info ) )`\nRecieves the entire spreadsheet. The `rows` object is an object in the same format as the cells you `add()`, so `add(rows)` will be valid. The `info` object looks like:\n\n```\n{\n spreadsheetId: 'ttFmrFPIipJimDQYSFyhwTg',\n worksheetId: 'od6',\n worksheetTitle: 'Sheet1',\n worksheetUpdated: '2013-05-31T11:38:11.116Z',\n authors: [ { name: 'jpillora', email: '[email protected]' } ],\n totalCells: 1,\n totalRows: 1,\n lastRow: 3,\n nextRow: 4\n}\n```\n\n`options.getValues` Always get the values (results) of forumla cells.\n\n##### spreadsheet.`metadata( [data, ] callback )`\n\nGet and set metadata\n\n*Note: when setting new metadata, if `rowCount` and/or `colCount` is left out,\nan extra request will be made to retrieve the missing data.*\n\n##### spreadsheet.`raw`\n\nThe raw data recieved from Google when enumerating the spreedsheet and worksheet lists, *which are triggered when searching for IDs*. In order to see this array of all spreadsheets (`raw.spreadsheets`) the `spreadsheetName` option must be used. Similarly for worksheets (`raw.worksheets`), the `worksheetName` options must be used.\n\n#### Optionsc\n\n##### `callback`\nFunction returning the authenticated Spreadsheet instance.\n\n##### `debug`\nIf `true`, will display colourful console logs outputing current actions.\n\n##### `username` `password`\nGoogle account - *Be careful about committing these to public repos*.\n\n##### `oauth`\nOAuth configuration object. See [google-oauth-jwt](https://github.com/extrabacon/google-oauth-jwt#specifying-options). *By default `oauth.scopes` is set to `['https://spreadsheets.google.com/feeds']` (`https` if `useHTTPS`)*\n\n##### `accessToken`\nReuse a generated access `token` of the given `type`. If you set `accessToken` to an object, reauthentications will not work. Instead use a `function accessToken(callback(err, token)) { ... }` function, to allow token generation when required.\n\n##### `spreadsheetName` `spreadsheetId`\nThe spreadsheet you wish to edit. Either the Name or Id is required.\n\n##### `worksheetName` `worksheetId`\nThe worksheet you wish to edit. Either the Name or Id is required.\n\n##### `useHTTPS`\nWhether to use `https` when connecting to Google (default: `true`)\n\n#### Todo\n\n* Create New Spreadsheets\n* Read specific range of cells\n* Option to cache auth token in file\n\n#### FAQ\n\n* Q: How do I append rows to my spreadsheet ?\n* A: Using the `info` object returned from `receive()`, one could always begin `add()`ing at the `nextRow`, thereby appending to the spreadsheet.\n\n#### Credits\n\nThanks to `googleclientlogin` for easy Google API ClientLogin Tokens\n\n#### References\n\n* https://developers.google.com/google-apps/spreadsheets/\n* https://developers.google.com/google-apps/documents-list/\n\n#### Donate\n\nBTC 1AxEWoz121JSC3rV8e9MkaN9GAc5Jxvs4\n\n#### MIT License\n\nCopyright © 2014 Jaime Pillora <[email protected]>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
"readmeFilename": "README.md",
"description": "> A simple API for reading and writing Google Spreadsheets in Node.js",
"bugs": {
"url": "https://github.com/jpillora/node-edit-google-spreadsheet/issues"
},
"homepage": "https://github.com/jpillora/node-edit-google-spreadsheet",
"_id": "[email protected]",
"dist": {
"shasum": "87b09d756db0190b12a9189f5c9ecc1dd81c56ba"
},
"_from": "edit-google-spreadsheet@~0.2.5",
"_resolved": "https://registry.npmjs.org/edit-google-spreadsheet/-/edit-google-spreadsheet-0.2.6.tgz"
}