Appending rows with empty cells results in increasing row indentation
See original GitHub issueEnvironment info
Operating System: Windows 10 Python version: 3.6.3 (Anaconda) gspread version: both 2.0.0 and 2.1.1
Steps to reproduce
ws = sheet.worksheet('Sheet1')
ws.append_row(['Test1', '', 'Test2'])
ws.append_row(['Test1', '', 'Test2'])
ws.append_row(['Test1', '', 'Test2'])
Output
It looks like new rows appended with append_row()
start from the last populated column on the previous rows. This is a relatively new behaviour that started a day or so ago.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Insert a Blank Row after Every Row in Excel (or Every Nth Row)
In this tutorial, I will show you some really simple ways to insert a blank row after every row in the existing dataset...
Read more >Adjust indents and spacing - Microsoft Support
Use Paragraph settings to change indentation, line spacing, and alignment.
Read more >Please help....bold row based on indent - Mr. Excel
Please help write a macro that will bold entire rows based on no indentation.
Read more >How to change alignment in Excel, justify, distribute and fill cells
In Microsoft Excel, the Tab key does not indent text in a cell like it does, say, in Microsoft Word; it just moves...
Read more >Excel table not formatting new rows appropriately - Super User
To resolve this click on the header of a column then right click and choose "Format Cells" option and set the desired format....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks like this is not a bug. I tried to run
append_row()
with different table layouts and it appears that the row shift happens when the Sheets API has multiple logical “tables” to chose from and it selects the rightmost. It’s explained in details in the example in the Sheets API guide here: https://developers.google.com/sheets/api/guides/values#appending_valuesSo In this particular case, when appending the second row the Sheets API sees two logical “tables” A1 and C1 and decides to append to C1:
When appending the third the same happens with E2 and so on.
As the Sheets API guide suggests the solution is to explicitly tell the Sheets API which table it needs to append to. For that, we’ll need to pass an explicit
range
parameter to the API call. I’ve implemented this in #726 (and named the parametertable_range
).So for this particular case, after #726 is merged you’ll need to call
append_row
this way:That way the API will know that you’d like to append to the table that starts with A1 cell. Again, this is only need in the case where there’s ambiguity in the selection of logical “tables”.
… Still happening.