Coder Social home page Coder Social logo

google-sheets's Introduction

Google Sheets

A simple to use library for interacting with Google Spreadsheets.

Features (todo list)

Spreadsheets

  • List
  • Get

Worksheets

  • List
  • Get
  • Add
  • Remove
  • Resize

Rows

  • List
  • Orderby & reverse support
  • Simple Query support
  • Remove
  • Modify

Cells

  • Modify
  • Get

How to use

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(err, sheets) {
			// sheets is an array of Spreadsheet objects
		});

		// load a specific sheet
		gsheets.getSpreadsheet(<YOUR SPREADSHEET KEY HERE>, function(err, sheet) {
			if (err) {
				throw err;
			}

			// sheet is a Spreadsheet object....lets list all its worksheets
			sheet.getWorksheets(function(err, worksheets) {
				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(err, worksheet) {
					// worksheet now refers to the updated worksheet object
					// lets get its rows and add some new ones
					worksheet.getRows(function(err, rows) {
						rows.create({
							id: 1,
							date: new Date().toUTCString(),
							value: 'A new value'
						}, function(err, row) {
							// now delete it again
							rows.remove(row, function(err) {
								// remove succeeded
							});
						});
					});
				});
			});

		});
	}	
});

Documentation

Authorization

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) {

Spreadsheets

List

Get

Worksheets

List

Get

Rename

Resize

Rows

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.

Get Rows

Orderby

Reverse

Simple Query

Modify Rows

Cells

Cells support is not currently implemented but is planned.

google-sheets's People

Contributors

balupton avatar benjamind avatar mikeal avatar tedjt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.