node-google-spreadsheet icon indicating copy to clipboard operation
node-google-spreadsheet copied to clipboard

Deleting method is not the same as deleting row manually in the web browser

Open NewCoderOnTheBlock opened this issue 2 years ago • 8 comments

Hello everyone! my issue is an aesthetic kinda issue.

I prepare some screenshoot to help my self to explain the problem Here you can see in the first screen shoot, 3 rows & I would like my bot to delete the row in the middle, so I call my method .delete() to do so. First screenshoot: trev

What happen is that I can see in the google sheet history that the value got actually replaced

trev2

& the other cell value the row was deleted

trev4

so I concluded the row was actually Cleared & move up. Which I totally did not want to do that, it mess my google sheet history, it becomes unreadable, unorganised.

web

I would like it to behave like "delete row" that we find in the browser Any help would much appreciated.

NewCoderOnTheBlock avatar Sep 01 '22 23:09 NewCoderOnTheBlock

@NewCoderOnTheBlock did you figure out how to delete the row like it is done on the web? I have the same issue, it clears the row but does not delete it which creates gaps in my sheet

cesar3030 avatar Dec 01 '23 18:12 cesar3030

@cesar3030 Hey, here's the code I wrote so the row gets deleted like it is done on the web: image

NewCoderOnTheBlock avatar Dec 01 '23 18:12 NewCoderOnTheBlock

Seems like this should maybe just be an option on how row.delete works? Or perhaps it should be the default? I suspect most folks don't really care...

I think the only difference would be that the dimensions of the sheet change versus just shifting the data up.

theoephraim avatar Dec 01 '23 18:12 theoephraim

@theoephraim I personally care deeply about this matter because if the rows are shifted, it will alter the cells in the Google Sheet history, rendering Google Sheets functionally useless

NewCoderOnTheBlock avatar Dec 01 '23 18:12 NewCoderOnTheBlock

@NewCoderOnTheBlock - apologies if I sounded dismissive - I meant most folks that aren't paying attention to the history like you wouldn't care if it worked this way (totally removing the row using deleteDimension) instead of shifting the data updward (using deleteRange).

theoephraim avatar Dec 01 '23 18:12 theoephraim

@theoephraim true true!

NewCoderOnTheBlock avatar Dec 01 '23 18:12 NewCoderOnTheBlock

@NewCoderOnTheBlock Thanks for the answer. I had issues with row shifting so I decided to keep a local state of the rows that I wanted to keep, wipe the spreadsheet and add back the rows I wanted to keep. This allows me to achieve my goal in 2 api calls and fix the row shifting issue.

cesar3030 avatar Dec 07 '23 17:12 cesar3030

@cesar3030 that's great! the shifting row was indeed annoying, I did it in one API call. My memory is fuzzy i did it long time ago.
in this line of code it contain my request; const requests = deleteRequests.concat([appendRequests]); (the one u see in my screenshoot)

NewCoderOnTheBlock avatar Dec 13 '23 14:12 NewCoderOnTheBlock