
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
edit-google-spreadsheet
Advanced tools
Currently, there are about 3 different node modules which allow you to read data off Google Spreadsheets, though none with a good write API. Enter `edit-google-spreadsheet`. A simple API for reading and updating Google Spreadsheets.
Currently, there are about 3 different node modules which allow you to read data off Google Spreadsheets, though none with a good write API. Enter edit-google-spreadsheet
. A simple API for reading and updating Google Spreadsheets.
npm install edit-google-spreadsheet
Create sheet with client login:
var Spreadsheet = require('edit-google-spreadsheet');
Spreadsheet.create({
debug: true,
username: '...',
password: '...',
spreadsheetName: 'node-edit-spreadsheet',
worksheetName: 'Sheet1',
callback: sheetReady
});
Note: Using the options spreadsheetName
and worksheetName
will cause lookups for spreadsheetId
and worksheetId
. Use spreadsheetId
and worksheetId
for improved performance.
Create sheet with OAuth:
var Spreadsheet = require('edit-google-spreadsheet');
Spreadsheet.create({
debug: true,
oauth : {
email: 'some-id@developer.gserviceaccount.com',
keyFile: 'private-key.pem'
},
spreadsheetName: 'node-edit-spreadsheet',
worksheetName: 'Sheet1',
callback: sheetReady
});
Update sheet:
function sheetReady(err, spreadsheet) {
if(err) throw err;
spreadsheet.add({ 3: { 5: "hello!" } });
spreadsheet.send(function(err) {
if(err) throw err;
console.log("Updated Cell at row 3, column 5 to 'hello!'");
});
}
Read sheet:
function sheetReady(err, spreadsheet) {
if(err) throw err;
spreadsheet.receive(function(err, rows, info) {
if(err) throw err;
console.log("Found rows:", rows);
// Found rows: { '3': { '5': 'hello!' } }
});
}
add
ExamplesBatch edit:
spreadsheet.add([[1,2,3],
[4,5,6]]);
Batch edit starting from row 5:
spreadsheet.add({
5: [[1,2,3],
[4,5,6]]
});
Batch edit starting from row 5, column 7:
spreadsheet.add({
5: {
7: [[1,2,3],
[4,5,6]]
}
});
Formula building with named cell references:
spreadsheet.add({
3: {
4: { name: "a", val: 42 }, //'42' though tagged as "a"
5: { name: "b", val: 21 }, //'21' though tagged as "b"
6: "={{ a }}+{{ b }}" //forumla adding row3,col4 with row3,col5 => '=D3+E3'
}
});
Note: cell a
and b
are looked up on send()
add( obj | array )
Add cells to the batch. See examples.
send( callback( err ) )
Sends off the batch of add()
ed cells. Clears all cells once complete.
receive( 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,
nextRow: 4
}
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']
(http
if not useHTTPS
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
)
info
object returned from receive()
, one could always begin add()
ing at the nextRow
, thereby appending to the spreadsheet.Thanks to googleclientlogin
for easy Google API ClientLogin Tokens
FAQs
> A simple API for reading and writing Google Spreadsheets in Node.js
We found that edit-google-spreadsheet demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.