Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Way to clear entire sheet? #45

Closed
zdbrandt opened this issue Jul 9, 2015 · 3 comments
Closed

Way to clear entire sheet? #45

zdbrandt opened this issue Jul 9, 2015 · 3 comments

Comments

@zdbrandt
Copy link

zdbrandt commented Jul 9, 2015

I'm working on a node app that reads data from a Mongo database and writes to a Google spreadsheet using this package. The task is going to happen every night. Is there a way to overwrite the rows that were created the previous night? It appears like new rows added using my_sheet.addRows gets added to the bottom.

I was looking into deleting the rows from the previous night but it looks like I can only delete on at a time. Is there a way to delete/clear the entire sheet? Thanks for this package! It's just what I need.

Zach

@theoephraim
Copy link
Owner

If you look in the tests, I am clearing the sheet there, but it's just using getRows and then async to call .del() on each row. If you had a huge sheet, you could end up hitting some limits, or it may just be too slow.

To clear the sheet in a single call, it looks like you would need to use a batch request, which is only available on cell-based feeds. More info here: https://developers.google.com/google-apps/spreadsheets/data#update_multiple_cells_with_a_batch_request

Currently, the module does not support batch requests on cell-based feeds, but I'm happy to merge in a PR!

@zakyg
Copy link

zakyg commented Aug 9, 2015

getting errors when attempting to delete all rows asynchronously with bluebird's Promise.all. As OP said, it seems that you'll have to chain and delete them one by one somehow, otherwise you'll get errors that the "row_id" you're trying to delete isn't valid.

@theoephraim
Copy link
Owner

Batch updates for cells is now supported! So you could make cells request, clear all the values, and then do a bulk update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants