jpillora / jpillora/node-edit-google-spreadsheet
Feature: Worksheet API
Nobody has claimed this yet.
- 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.jswill be comeworksheet.jssince metadata is actually a worksheet API call - The
Metadataclass would be become aWorksheetclass - On
Spread.loadall of the spreadsheets worksheets should be instantiated inspreadsheet.worksheetsand if (now optional)worksheetNamewas set, then it would be set tospreadsheet.worksheet(the current worksheet). - Important To make this change backwards compatible
spreadsheet.send()/receive()actually callspreadsheet.worksheet.send()/receive() - Finally, there's new APIs to add and remove worksheets
spreadsheet.load(title, callback(err, worksheet))(If it's already inworksheetsno request is needed, otherwise it will refresh the worksheet list. On successworksheetbecomes the new currentspreadsheet.worksheet)spreadsheet.create(title, [numColumns, numRows], callback(err, worksheet))(Operates as an "upsert" – adds if necessary. On successworksheetbecomes the new currentspreadsheet.worksheet)spreadsheet.delete(title, callback(err))- As these calls are made
spreadsheet.worksheetsis 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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