jpillora / jpillora/node-edit-google-spreadsheet

Feature: Worksheet API

Open
#56 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
JavaScript
Stars
301
Forks
98
PR merge metrics
No merged PRs in 30d

Description

Looking for Contributors Please look through these notes and then the source and if you decide to give this a shot, mention that you're working on this in the comments below and I'll give you push access.


A spreadsheet is the entire document, and a worksheet is a tab in the document. Currently this module models 1 spreadsheet and 1 worksheet, it should actually model N worksheets, just as spreadsheets do. The proposed feature would result in the API below. Please +1 below so we can gauge interest. I've specified a rough outline of the changes that need to be made, though they're subject to change.

A few initial notes:

  • Adding and deleting spreadsheets is out of scope, see the google-drive module
  • The metadata.js will be come worksheet.js since metadata is actually a worksheet API call
  • The Metadata class would be become a Worksheet class
  • On Spread.load all of the spreadsheets worksheets should be instantiated in spreadsheet.worksheets and if (now optional) worksheetName was set, then it would be set to spreadsheet.worksheet (the current worksheet).
  • Important To make this change backwards compatible spreadsheet.send()/receive() actually call spreadsheet.worksheet.send()/receive()
  • Finally, there's new APIs to add and remove worksheets
    • spreadsheet.load(title, callback(err, worksheet)) (If it's already in worksheets no request is needed, otherwise it will refresh the worksheet list. On success worksheet becomes the new current spreadsheet.worksheet)
    • spreadsheet.create(title, [numColumns, numRows], callback(err, worksheet)) (Operates as an "upsert" – adds if necessary. On success worksheet becomes the new current spreadsheet.worksheet)
    • spreadsheet.delete(title, callback(err))
    • As these calls are made spreadsheet.worksheets is being kept up to date

See prototype code:

Spreadsheet.load({
  username: creds.username,
  password: creds.password,
  spreadsheetName: 'node-edit-spreadsheet',
  worksheetName: 'Sheet1'  //worksheet becomes optional
}, function run(err, spreadsheet) {
  if(err) throw err;

  spreadsheet.worksheets === [ /* worksheet instances */, /* */ ];
  spreadsheet.worksheet === { /* Sheet1 instance */ };

  //now
  spreadsheet.send();
  spreadsheet.receive();
  //actually does
  spreadsheet.worksheet.send();
  spreadsheet.worksheet.receive();

  //and there's now 'load', 'create' and 'delete' methods

  spreadsheet.load("Sheet 3", function(err, worksheet) {
    //...
  });

  spreadsheet.create("Sheet 2", function(err, worksheet) {
    //...
  });

  spreadsheet.delete("Sheet 1", function(err) {
    //...
  });

});

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading metadata.js and the surrounding source for Spreadsheet.load, send, and receive. Compare the current model with the proposed prototype, then define the worksheet collection and load/create/delete behavior. Done means multiple worksheets are represented, the current worksheet remains backwards compatible, and the worksheet list stays updated.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.