Strange addRow behaviour depending on contents of previous rows
See original GitHub issueI have a 2 sheets of invoices (a and b), and I am using v3.0.11 of node-google-spreadsheet to write to these:
await a.addRow(invoice, { insert: true });
and
await b.addRow(invoice, { insert: true });
Strangely, everything added to ‘a’ has added properly, but each line in ‘b’ staggers - invoice 1 starts in column A, but then invoice 2 starts in column W, and then invoice 3 a further 22 columns later - column AS (there are 26 object memebers in an invoice - so invoice one occupies columns A-Z)
After much testing, I found that if I delete the pre-existing data in the sheet for all ‘b’ invoices (leaving the header row in row 1) it stops staggering on the writes. When I put it back, it starts staggering again. So somehow the existing data is having an effect on the writing of the row, and staggering it?!?!
I also tested with addRow and addRows, and {insert: true} present and absent, same issue.
If there is any more info I can supply, or testing I can do, please feel free to let me know,
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (1 by maintainers)
Top GitHub Comments
Hey guys - so I think I have this solved. Basically the google API looks for the right “table” (continuous grid of data) to insert the data into and when there are gaps, some weird things can happen. By telling the endpoint to look for data starting at cell A1, it seems to operate as expected.
Deploying the fix shortly.
Yes same issue in my case when having blank cells in the sheet, Specially if the headers are blank. The issue gets resolved once I remove all the blank cells…But I do require a few blank cells in my sheets sometimes.