google-sheets

Read and modify Google Spreadsheets

Google Sheets

A simple to use library for interacting with Google Spreadsheets.

  • [x] List
  • [x] Get
  • [x] List
  • [x] Get
  • [x] Add
  • [x] Remove
  • [x] Resize
  • [x] List
  • [x] Orderby & reverse support
  • [x] Simple Query support
  • [x] Remove
  • [x] Modify
  • [ ] Modify
  • [ ] Get
var gsheets = require('google-sheets');
 
// authorize your account 
gsheets.auth({
    email: <YOUR GOOGLE USERNAME>,
    password: <YOUR GOOGLE PASS>
}, function(err) {
    if (err) {
        throw err;
 
        // list spreadsheets in the account 
        gsheets.list(function(errsheets) {
            // sheets is an array of Spreadsheet objects 
        });
 
        // load a specific sheet 
        gsheets.getSpreadsheet(<YOUR SPREADSHEET KEY HERE>, function(errsheet) {
            if (err) {
                throw err;
            }
 
            // sheet is a Spreadsheet object....lets list all its worksheets 
            sheet.getWorksheets(function(errworksheets) {
                if (err) {
                    throw err;
                }
                // loop over the worksheets and print their titles 
                Array.forEach(worksheets, function(worksheet) {
                    console.log('Worksheet : ' + worksheet.getTitle());
                });
 
                // set size of first worksheet 
                worksheets[0].set({
                    rows: 50,
                    cols: 50
                });
                // save it 
                worksheet[0].save(function(errworksheet) {
                    // worksheet now refers to the updated worksheet object 
                    // lets get its rows and add some new ones 
                    worksheet.getRows(function(errrows) {
                        rows.create({
                            id: 1,
                            date: new Date().toUTCString(),
                            value: 'A new value'
                        }, function(errrow) {
                            // now delete it again 
                            rows.remove(row, function(err) {
                                // remove succeeded 
                            });
                        });
                    });
                });
            });
 
        });
    }   
});

Current Google Sheets only supports authorized usage via GoogleClientLogin. It also only supports accessing spreadsheets through the private urls with the full projection. If this doesn't make any sense go read the Google Spreadsheets API documentation.

var gsheets = require('google-sheets');
 
// authorize your account 
gsheets.auth({
    email: <YOUR GOOGLE USERNAME>,
    password: <YOUR GOOGLE PASS>
}, function(err) {

Rows support is operational, but is not yet stable. The interface is likely to change as I don't like the architecture currently, however it does all currently work.

Cells support is not currently implemented but is planned.