node-google-spreadsheet
node-google-spreadsheet copied to clipboard
Passing Empty String as value causes addRow to overwrite row 1
I have a spreadsheet with a protected first row (1:1 range), which contains the header values I reference in dot notation when adding rows to my spreadsheet. I discovered today that passing the empty string will cause the function to attempt to overwrite the first row instead of appending the data to the last row. Luckily, it returned an error because it is a protected range. For example, the following would cause the issue:
await sheet.addRow({ date: "today", number: "5", customer: "" });
While the below would append to the last spreadsheet row, as expected:
await sheet.addRow({ date: "today", number: "5", customer: "Bob" });
I am working around the empty string values in my code, by converting them to null, which still allows the function to append, while also having (possibly) blank cells:
await sheet.addRow({ date: "today", number: "5", customer: null });
No action needed, just wanted to post this as a possible improvement idea, or to be of help if someone else has the same problem.
Very odd - I'll have to check that out! It's definitely not expected behaviour.
I am having the same issue, so I really appreciate you writing this up @jwhiteaei so I can do the workaround!
Scratch that. I'm definitely not passing in empty strings but every so often the first row is overwritten. I can't see any consistent pattern in the values as to why some work and some don't. Weird.
@cjbeattie - if you can share a copy of your sheet with me ([email protected]) and a code example, I can try to take a look
closing this - please send more details and reopen if you are still having issues.