Gathering detailed insights and metrics for edit-google-spreadsheet
Gathering detailed insights and metrics for edit-google-spreadsheet
Gathering detailed insights and metrics for edit-google-spreadsheet
Gathering detailed insights and metrics for edit-google-spreadsheet
zetta-spreadsheet-google-driver
This is a simple state machine that wraps the [edit google spreadsheet module](https://github.com/jpillora/node-edit-google-spreadsheet). This state machine isn't meant to be consumed in the API, it should be used only in apps or in other state machines.
@fmpanelli/sheet-table-editor
Support library to edit a Google spreadsheet in tabular format
npm install edit-google-spreadsheet
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
1,890,153
Last Day
349
Last Week
2,297
Last Month
10,102
Last Year
70,881
304 Stars
143 Commits
101 Forks
28 Watchers
2 Branches
17 Contributors
Updated on May 04, 2024
Latest Version
0.3.0
Package Id
edit-google-spreadsheet@0.3.0
Size
11.60 kB
NPM Version
5.3.0
Node Version
8.5.0
Cumulative downloads
Total Downloads
Last Day
16.7%
349
Compared to previous day
Last Week
-3%
2,297
Compared to previous week
Last Month
13.3%
10,102
Compared to previous month
Last Year
133.9%
70,881
Compared to previous year
5
A simple API for reading and writing Google Spreadsheets in Node.js
This module aims to be a complete wrapper around the Google Sheets API version 3.0. If anything is missing, create an issue, or even better, a pull request.
:warning: Google has finally deprecated ClientLogin, which means you can no longer authenticate with your email and password. See https://github.com/jpillora/node-edit-google-spreadsheet/issues/72 for updates.
npm install edit-google-spreadsheet
Load a spreadsheet:
1 var Spreadsheet = require('edit-google-spreadsheet'); 2 3 Spreadsheet.load({ 4 debug: true, 5 spreadsheetName: 'edit-spreadsheet-example', 6 worksheetName: 'Sheet1', 7 8 // Choose from 1 of the 5 authentication methods: 9 10 // 1. Username and Password has been deprecated. OAuth2 is recommended. 11 12 // OR 2. OAuth 13 oauth : { 14 email: 'my-name@google.email.com', 15 keyFile: 'my-private-key.pem' 16 }, 17 18 // OR 3. OAuth2 (See get_oauth2_permissions.js) 19 oauth2: { 20 client_id: 'generated-id.apps.googleusercontent.com', 21 client_secret: 'generated-secret', 22 refresh_token: 'token generated with get_oauth2_permission.js' 23 }, 24 25 // OR 4. Static Token 26 accessToken: { 27 type: 'Bearer', 28 token: 'my-generated-token' 29 }, 30 31 // OR 5. Dynamic Token 32 accessToken: function(callback) { 33 //... async stuff ... 34 callback(null, token); 35 } 36 }, function sheetReady(err, spreadsheet) { 37 //use speadsheet! 38 });
Note: Using the options spreadsheetName
and worksheetName
will cause lookups for spreadsheetId
and worksheetId
. Use spreadsheetId
and worksheetId
for improved performance.
Update sheet:
1 function sheetReady(err, spreadsheet) { 2 if(err) throw err; 3 4 spreadsheet.add({ 3: { 5: "hello!" } }); 5 6 spreadsheet.send(function(err) { 7 if(err) throw err; 8 console.log("Updated Cell at row 3, column 5 to 'hello!'"); 9 }); 10 }
Read sheet:
1 function sheetReady(err, spreadsheet) { 2 if(err) throw err; 3 4 spreadsheet.receive(function(err, rows, info) { 5 if(err) throw err; 6 console.log("Found rows:", rows); 7 // Found rows: { '3': { '5': 'hello!' } } 8 }); 9 10 }
async
/ await
UsageAll functions which have a callback
return a Promise
tied
to that callback and can therefore be used with async
/ await
.
1 2const Spreadsheet = require("../"); 3 4(async function example() { 5 let spreadsheet = await Spreadsheet.load({ 6 debug: true, 7 oauth2: ..., 8 spreadsheetName: "node-spreadsheet-example", 9 worksheetName: "Sheet1" 10 }); 11 //receive all cells 12 let [rows, info] = await spreadsheet.receive({getValues: false}); 13 console.log("Found rows:", rows); 14 console.log("With info:", info); 15})().catch;
Get metadata
1 function sheetReady(err, spreadsheet) { 2 if(err) throw err; 3 4 spreadsheet.metadata(function(err, metadata){ 5 if(err) throw err; 6 console.log(metadata); 7 // { title: 'Sheet3', rowCount: '100', colCount: '20', updated: [Date] } 8 }); 9 }
Set metadata
1 function sheetReady(err, spreadsheet) { 2 if(err) throw err; 3 4 spreadsheet.metadata({ 5 title: 'Sheet2' 6 rowCount: 100, 7 colCount: 20 8 }, function(err, metadata){ 9 if(err) throw err; 10 console.log(metadata); 11 }); 12 }
WARNING: all cells outside the range of the new size will be silently deleted
add
ExamplesBatch edit:
1spreadsheet.add([[1,2,3], 2 [4,5,6]]);
Batch edit starting from row 5:
1spreadsheet.add({ 2 5: [[1,2,3], 3 [4,5,6]] 4});
Batch edit starting from row 5, column 7:
1spreadsheet.add({ 2 5: { 3 7: [[1,2,3], 4 [4,5,6]] 5 } 6});
Formula building with named cell references:
1spreadsheet.add({ 2 3: { 3 4: { name: "a", val: 42 }, //'42' though tagged as "a" 4 5: { name: "b", val: 21 }, //'21' though tagged as "b" 5 6: "={{ a }}+{{ b }}" //forumla adding row3,col4 with row3,col5 => '=D3+E3' 6 } 7});
Note: cell a
and b
are looked up on send()
Spreadsheet.load( options, callback( err, spreadsheet ) )
See Options below
add( obj | array )
Add cells to the batch. See examples.
send( [options,] callback( err ) )
Sends off the batch of add()
ed cells. Clears all cells once complete.
options.autoSize
When required, increase the worksheet size (rows and columns) in order to fit the batch - NOTE: When enabled, this will trigger an extra request on every send()
(default false
).
receive( [options,] callback( err , rows , info ) )
Recieves 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:
{
spreadsheetId: 'ttFmrFPIipJimDQYSFyhwTg',
worksheetId: 'od6',
worksheetTitle: 'Sheet1',
worksheetUpdated: '2013-05-31T11:38:11.116Z',
authors: [ { name: 'jpillora', email: 'dev@jpillora.com' } ],
totalCells: 1,
totalRows: 1,
lastRow: 3
}
options.getValues
Always get the values (results) of forumla cells.
metadata( [data, ] callback )
Get and set metadata
Note: when setting new metadata, if rowCount
and/or colCount
is left out,
an extra request will be made to retrieve the missing data.
raw
The 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.
callback
Function returning the authenticated Spreadsheet instance.
debug
If true
, will display colourful console logs outputing current actions.
username
password
Google account - Be careful about committing these to public repos.
oauth
OAuth configuration object. See google-oauth-jwt. By default oauth.scopes
is set to ['https://spreadsheets.google.com/feeds']
(https
if useHTTPS
)
accessToken
Reuse 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.
spreadsheetName
spreadsheetId
The spreadsheet you wish to edit. Either the Name or Id is required.
worksheetName
worksheetId
The worksheet you wish to edit. Either the Name or Id is required.
useHTTPS
Whether to use https
when connecting to Google (default: true
)
useCellTextValues
Return text values for cells or return values as typed. (default: true
)
info
object returned from receive()
, one could always begin add()
ing at the lastRow + 1
, thereby appending to the spreadsheet.Thanks to googleclientlogin
for easy Google API ClientLogin Tokens
BTC 1AxEWoz121JSC3rV8e9MkaN9GAc5Jxvs4
Copyright © 2015 Jaime Pillora <dev@jpillora.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 4/20 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
47 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More