Métricas do repositório
- Stars
- (302 stars)
- Métricas de merge de PR
- (Métricas PR pendentes)
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) {
//...
});
});