Downloading a particular tab of a Google Sheets spreadsheet

1,903 views
Skip to first unread message

Immanuel Burton

unread,
Jun 28, 2018, 12:02:19 PM6/28/18
to GAM for G Suite
The following GAM command:

gam user xxxx...@somewhere.com get drivefile id 1234567890abcdefghijklmnopqrstuvwxyz format csv

downloads the first tab of the spreadsheet in question as a CSV file.

If I know either the name or GID of a particular tab in the spreadsheet, is there a way of downloading just that tab?  I have no way of guaranteeing that the tab that I want to download will always be the first tab, as other users may (for reasons known best to themselves) with whom the spreadsheet is shared may move tabs around.

Thank you.

Immanuel Burton.

+KimNilsson

unread,
Jul 6, 2018, 12:21:29 PM7/6/18
to GAM for G Suite
Just use the full URL of the tab instead of just the id, with the GID part.

gam user userATdomain get drivefile https://docs.google.com/spreadsheets/d/1234567890abcdefghijklmnopqrstuvwxyz/edit#gid=123456789 format csv

Immanuel Burton

unread,
Jul 6, 2018, 2:52:51 PM7/6/18
to GAM for G Suite
Thank you for your reply.

I'd tried that, but the version of GAM that I'm using doesn't accept a URL as a file identifier.

I have, however, devised a workaround.  What I did was to create a new Google Sheets file, and use an importrange formula to import the data from the tab in the original spreadsheet.  I can then use GAM to download the data from this new spreadsheet, and as this new spreadsheet has only one tab, there's no issue with making sure that I'm getting the right tab in my download.

Kim Nilsson

unread,
Jul 6, 2018, 5:24:34 PM7/6/18
to Google Apps Manager
Yup, that'd work too. :-)

/Kim
--
There is No Substitute!
Reply all
Reply to author
Forward
0 new messages